public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// TODO Auto-generated method stub
Bundle programNum = getIntent().getExtras();
final int progNum = programNum.getInt("Program");
Intent intent = new Intent(getBaseContext(), hotelAct3.class);
String hotelName = (String) ((TextView)parent.getChildAt(position)).getText();
startActivity(intent);
}
它应该来自调用列表活动的活动:这样我就有一个活动“hotelAct2.class”在里面我放了额外的数据
公共类hotelAct2扩展活动{
EgyptDataSource datasource;
MySQLiteHelper sqlHelper;
ArrayAdapter<Hotel> hotelAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.hotelq2);
Bundle programNum = getIntent().getExtras();
final int progNum = programNum.getInt("Program");
final String Srating = programNum.getString("Stars");
//Intent ratingIntent = getIntent();
//String Srating = ratingIntent.getStringExtra("Stars");
Toast.makeText(hotelAct2.this, "The program is " + progNum + " The rating is " + Srating, Toast.LENGTH_LONG).show();
RadioButton nileRB = (RadioButton) findViewById(R.id.hRB2a);
RadioButton pyramidsRB = (RadioButton) findViewById(R.id.hRB2b);
RadioButton downtownRB = (RadioButton) findViewById(R.id.hRB2c);
RadioButton letmeRB = (RadioButton) findViewById(R.id.hRB2d);
if(Srating.equals("Five"))
{
nileRB.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(hotelAct2.this, CairoHotelList.class);
i.putExtra("RB", "nile5");
i.putExtra("program", progNum);
startActivity(i);
}});
然后它启动“CairoHotelList.class”的活动列表我想在活动类的onItemClickListener中获取额外的数据
“progNum”返回 0,而它应该返回一个从 1 到 20 的数字,有什么帮助吗?