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は」私はActivityクラスのonItemClickListener
「Pに余分なデータを取得したいされたアクティビティのリストを開始しますrogNumは1から20までの数値を返す必要がある間に0を返します。
「プログラム」をインテントに追加するコードを含めてください。 – Luke