在我的第四节课中,选定的文本不会只显示粗体早餐会显示粗体午餐和晚餐当我按下 img2 或 img3 时不会显示粗体告诉我我会做什么?所有值都显示在 Toast 上,但只有当 pres img 是 make 时才会使文本变为粗体 早餐将是粗体 午餐和晚餐不显示粗体
img1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent iMenuList = new Intent(thirdstep.this,
fourthscreen.class);
iMenuList.putExtra("Menuitem", txt1.getText().toString());
startActivity(iMenuList);
}
});
img2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent iMenuList = new Intent(thirdstep.this,
fourthscreen.class);
iMenuList.putExtra("Menuitem", txt2.getText().toString());
startActivity(iMenuList);
}
});
img3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent iMenuList = new Intent(thirdstep.this,
fourthscreen.class);
iMenuList.putExtra("Menuitem", txt3.getText().toString());
startActivity(iMenuList);
}
});
}
}
public class fourthscreen extends Activity
Breakfast = (TextView) findViewById(R.id.txtfourth1);
Lunch = (TextView) findViewById(R.id.txtfourth2);
Supper = (TextView) findViewById(R.id.txtfourth3);
Bundle bundle = this.getIntent().getExtras();
String param1 = bundle.getString("Menuitem");
Toast.makeText(fourthscreen.this, param1, Toast.LENGTH_LONG).show();
if(param1.equalsIgnoreCase("BreakFast"))
{
Breakfast.setTypeface(null, Typeface.BOLD);
}
else
if(param1.equalsIgnoreCase("Lunch"))
{
Lunch.setTypeface(null, Typeface.BOLD);
}
else
if(param1.equalsIgnoreCase("Supper"))
{
Lunch.setTypeface(null, Typeface.BOLD);
}