私は2つの単純なリストビューを作成しました。最初のリストビューでは、カテゴリをアイテム名として入れました。そしてそれは私がリスト1に含まれている唯一のアイテムです。私が知りたいオレンジ、アップル、マンゴー、バナナetc.whatのように、私はあなたが2番目のリストビューで1つの特定のアイテムを選択した場合、選択されたアイテムを最初のリストビューに表示されます。ユーザーが以前に選択したアイテムを識別するのは簡単です。私はonitemselected使用しますが、クリックオレンジ、何も起こっていないことになる場合リストビューで選択したアイテムを他のリストにバインドする方法はありますか?
public class listview extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.submain);
ListView mlistView = (ListView) findViewById(R.id.listview);
mlistView.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
new String[] {"orange", "apple","mango","banana","grapes"}));
mlistView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,long arg3){
Intent in2 =new Intent(listview.this, bview.class);
startActivity(in2);
}
public void onNothingSelected(AdapterView<?>arg0){
}});
}}
:
public class bview extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter(this,
android.R.layout.simple_list_item_1, cat));
getListView().setTextFilterEnabled(true);
}
static final String[] cat = new String[] {
"Category", };
protected void onListItemClick(ListView parent, View v, int position,
long id) {
Intent intent= new Intent(bview.this,listview.class);
startActivity(intent);
//intent.putExtra("value", value);
}}
第二のListViewコード:これは私の第一のリストビューコードです....
私を助けてください。私はコード内で間違っているはずです....
を参照して、最初のリストビューの選択した項目を設定することができます私のソースコードにソースコード...私はアンドロイドアプリケーションのための新しいです...私に教えてください...私のソースコードを投稿してください...私は確認してください... – balaji
私は私の答えで言ったように、これはコードは、2番目のアクティビティでonCreateメソッドに配置する必要があります。 –
今私は自分のコードを変更しましたが、何も起こりません。チェックして、私に教えてください.... – balaji