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」裏面我把額外的數據如何在Android中獲取OnItemClickListener中的額外數據?
公共類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」我想在活動課
的「p的onItemClickListener額外的數據rogNum「返回0,它應該返回一個從1到20的數字,有幫助嗎?
請問您可否在代碼中添加額外的「程序」到代碼中? – Luke 2012-04-24 21:11:59