選択したボタンの値をパラメーターとして別のアクティビティに渡す方法??? 以下は私のコードで、これはスクリーンショットですhttp://imgur.com/YkbE8AS 私のコードはカレンダーを水平方向に表示しますユーザーが水曜日のような週の任意の日を選択すると仮定しますその固定値は動的な値なので、選択した日の値を月で渡すにはどうすればよいですかおよび年をパラメーターとして別のアクティビティに???? テキストが動的な私の CDOE 7 ボタンで、ユーザーが任意の日をクリックしたときに、現在の月と年の値をパラメーターとして別のアクティビティに渡したいとします。クリック??
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);
}