如何将选定的按钮值作为参数传递给另一个活动???下面是我的代码,这是屏幕截图http://imgur.com/YkbE8AS 我的代码水平显示日历假设用户选择像星期三这样的一周中的任何一天它的不固定值是动态值所以我如何通过月份选择日期值并将年份作为参数传递给另一个活动????在我的 cdoe 7 按钮中,当用户单击具有当前月份和年份的值作为参数传递给另一个活动的任何一天时,我想要哪些文本是动态的,假设 abc.java 当按钮 mybutton 将点击??
public class HoyahCalendar extends Activity {
public static int mYear;
public static int currentIndex = -1;
public static int mMonth;
public static int mDay;
public static String[][] a = new String[6][7];
String January="January";
String February="February";
String March="March";
String April="April";
String May="May";
String June="June";
String Jully="Jully";
String August="August";
String September="September";
String October="October";
String November="November";
String December="December";
String Monthname;
TextView date_today;
ImageView last_month;
ImageView next_month;
ImageView last_week;
ImageView next_week;
Button e00;
Button e01;
Button e02;
Button e03;
Button e04;
Button e05;
Button e06;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getIntent().setAction("Already created");
date_today = (TextView) findViewById(R.id.date_today);
last_month = (ImageView) findViewById(R.id.last_month);
next_month = (ImageView) findViewById(R.id.next_month);
last_week = (ImageView) findViewById(R.id.last_week);
next_week = (ImageView) findViewById(R.id.next_week);
e00 = (Button) findViewById(R.id.e00);
e01 = (Button) findViewById(R.id.e01);
e02 = (Button) findViewById(R.id.e02);
e03 = (Button) findViewById(R.id.e03);
e04 = (Button) findViewById(R.id.e04);
e05 = (Button) findViewById(R.id.e05);
e06 = (Button) findViewById(R.id.e06);
Calendar mCalendar = Calendar.getInstance();
mYear = mCalendar.get(Calendar.YEAR);
mMonth = mCalendar.get(Calendar.MONTH) + 1;
mDay = mCalendar.get(Calendar.DAY_OF_MONTH);
last_month.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mMonth == 1) {
mYear -= 1;
mMonth = 12;
new ShowCalendar(mYear, mMonth);
showOnScreen();
} else {
mMonth -= 1;
new ShowCalendar(mYear, mMonth);
showOnScreen();
}
}
});
next_month.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mMonth == 12) {
mYear += 1;
mMonth = 1;
new ShowCalendar(mYear, mMonth);
showOnScreen();
} else {
mMonth += 1;
new ShowCalendar(mYear, mMonth);
showOnScreen();
}
}
});
last_week.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mMonth == 1) {
mYear -= 1;
mMonth = 12;
new ShowCalendar(mYear, mMonth, mDay, "last");
showOnScreen();
} else {
// mMonth -= 1;
new ShowCalendar(mYear, mMonth, mDay, "last");
showOnScreen();
}
}
});
next_week.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mMonth == 12) {
mYear += 1;
mMonth = 1;
new ShowCalendar(mYear, mMonth, mDay, "next");
showOnScreen();
} else {
if (HoyahCalendar.currentIndex == 4) {
HoyahCalendar.currentIndex = 4;
// mMonth += 1;
}
new ShowCalendar(mYear, mMonth, mDay, "next");
showOnScreen();
}
}
});
new ShowCalendar(mYear, mMonth);
showOnScreen();
}
public void showOnScreen() {
if (mMonth ==1)
{
Monthname="January";
}
else
if (mMonth ==2) {
Monthname="February";
}
else
if (mMonth ==3) { Monthname="March";}
else
if (mMonth ==4) { Monthname="April"; }
else
if (mMonth ==5) { Monthname="May";}
else
if (mMonth ==6) { Monthname="June"; }
else
if (mMonth ==7) { Monthname="July";}
else
if (mMonth ==8) { Monthname="August"; }
else
if (mMonth ==9) { Monthname="September";}
else
if (mMonth ==10) { Monthname="October"; }
if (mMonth ==11) { Monthname="November";}
else
if (mMonth ==12) { Monthname="December"; }
date_today.setText( Monthname + " " +mYear);
e00.setText("" + a[0][0]);
if(e00.getText().toString().equals(String.valueOf(mDay)))
{e00.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button1 text equals!", Toast.LENGTH_SHORT).show();
}
else
{
e00.setTextColor(Color.parseColor("#000000"));
}
e01.setText("" + a[0][1]);
if(e01.getText().toString().equalsIgnoreCase (String.valueOf(mDay)))
{
e01.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button2 text equals!", Toast.LENGTH_SHORT).show();
}
else
{
e01.setTextColor(Color.parseColor("#000000"));
}
e02.setText("" + a[0][2]);
if(e02.getText().toString().equals(String.valueOf(mDay)))
{e02.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button3 text equals!", Toast.LENGTH_SHORT).show();
}
else
{
e02.setTextColor(Color.parseColor("#000000"));
}
e03.setText("" + a[0][3]);
if(Integer.parseInt(e03.getText().toString()) == mDay)
{e03.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button4 text equals!", Toast.LENGTH_SHORT).show();
}
else
{
e03.setTextColor(Color.parseColor("#000000"));
}
e04.setText("" + a[0][4]);
if(e04.getText().toString().equals(String.valueOf(mDay)))
{e04.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button5 text equals!", Toast.LENGTH_SHORT).show();
}
else
{
e04.setTextColor(Color.parseColor("#000000"));
}
e05.setText("" + a[0][5]);
if(e05.getText().toString().equals(String.valueOf(mDay)))
{e05.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button6 text equals!", Toast.LENGTH_SHORT).show();
}
else
{
e05.setTextColor(Color.parseColor("#000000"));
}
e06.setText("" + a[0][6]);
if(e06.getText().toString().equals(String.valueOf(mDay)))
{e06.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button7 text equals!", Toast.LENGTH_SHORT).show();
}
else
{
e06.setTextColor(Color.parseColor("#000000"));
}
}
public void onRestart() {
super.onRestart();
Intent intent = getIntent();
finish();
startActivity(intent);
}