本帖最后由 敏敏好学 于 2014-9-21 19:30 编辑
终于做好啦!! 呼
给大家分享些代码
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
public class MainActivity extends Activity {
ImageView image;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image =(ImageView) findViewById(R.id.imageView1) ;
image.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.setClass(MainActivity.this,MainActivity_1.class);
startActivity(intent);
}
});
}
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity_1 extends Activity implements OnClickListener {
Intent intent ;
Button button,button1,button2,button3,button4,button5,button6,button7,
button8,button9,button10,button11,button12,button13,button14,button15,button16,button17;
String str="button1";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_1);
intent=this.getIntent();
button=(Button) findViewById(R.id .button );
button1=(Button) findViewById(R.id.button1 );
button2=(Button) findViewById(R.id.button2 );
button3=(Button) findViewById(R.id.button3 );
button4=(Button) findViewById(R.id.button4 );
button5=(Button) findViewById(R.id.button5 );
button6=(Button) findViewById(R.id.button6 );
button7=(Button) findViewById(R.id.button7 );
button8=(Button) findViewById(R.id.button8 );
button9=(Button) findViewById(R.id.button9 );
button10=(Button) findViewById(R.id.button10 );
button11=(Button) findViewById(R.id.button11 );
button12=(Button) findViewById(R.id.button12 );
button13=(Button) findViewById(R.id.button13 );
button14=(Button) findViewById(R.id.button14 );
button15=(Button) findViewById(R.id.button15 );
button16=(Button) findViewById(R.id.button16 );
button17=(Button) findViewById(R.id.button17 );
button.setOnClickListener(this);
button1.setOnClickListener(this);
button2.setOnClickListener(this);
button3.setOnClickListener(this);
button4.setOnClickListener(this);
button5.setOnClickListener(this);
button6.setOnClickListener(this);
button7.setOnClickListener(this);
button8.setOnClickListener(this);
button9.setOnClickListener(this);
button10.setOnClickListener(this);
button11.setOnClickListener(this);
button12.setOnClickListener(this);
button13.setOnClickListener(this);
button14.setOnClickListener(this);
button15.setOnClickListener(this);
button16.setOnClickListener(this);
button17.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.setClass(MainActivity_1.this,activity_text.class);
Bundle bund=new Bundle();
if(v==button)
{
bund.putString("list", str);
bund.putString("key", "18");
}
if(v==button1)
{
str="button1";
bund.putString("key", "1");
}
if(v==button2)
{
str="button2";
bund.putString("key", "2");
}
if(v==button3)
{
str="button3";
bund.putString("key","3");
}
if(v==button4)
{
str="button4";
bund.putString("key","4");
}
if(v==button5)
{
str="button5";
bund.putString("key","5");
}
if(v==button6)
{
str="button6";
bund.putString("key","6");
}
if(v==button7)
{
str="button7";
bund.putString("key","7");
}
if(v==button8)
{
str="button8";
bund.putString("key", "8");
}
if(v==button9)
{
str="button9";
bund.putString("key","9");
}
if(v==button10)
{
str="button10";
bund.putString("key", "10");
}
if(v==button11)
{
str="button11";
bund.putString("key", "11");
}
if(v==button12)
{
str="button12";
bund.putString("key", "12");
}
if(v==button13)
{
str="button13";
bund.putString("key", "13");
}
if(v==button14)
{
str="button14";
bund.putString("key", "14");
}
if(v==button15)
{
str="button15";
bund.putString("key","15");
}
if(v==button16)
{
str="button16";
bund.putString("key", "16");
}
if(v==button17)
{
str="button17";
bund.putString("key", "17");
}
intent.putExtras(bund);
startActivityForResult(intent,0);
}
}
|
|