-2

行动=1

    String[] values = new String[] { "Android", "iPhone", "WindowsMobile"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
     android.R.layout.simple_list_item_1, android.R.id.text1, values);
      lisdis.setAdapter(adapter); 
      lisdis.setOnItemClickListener(this);

}
@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long id)
{

    Intent mIntent = new Intent(display_publishermagazine.this, display_publicationmagazine.class);
        mIntent.putExtra("position", position+1);
        startActivity(mIntent);

行动=2

    Intent mIntent = getIntent();
    int intValue = mIntent.getIntExtra("position",0);

   switch (intValue)
    {
        case 1:values = new String[] { "Android For Beginer","Android Devloper" };break;
        case 2:values = new String[] { "I-phone for beginer","I-phone for devloper" };break;
        case 3:values = new String[] { "windows for beginer","windows for devloper" };break;
    }


    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
         android.R.layout.simple_list_item_1, android.R.id.text1, values);

lisdis.setAdapter(adapter); 
    lisdis.setOnItemClickListener(this);        
}

@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long id)
{
    Intent myIntent = new Intent(display_publishermagazine.this, display_publicationmagazine.class);


    myIntent.putExtra("position", position+1);
    startActivity(myIntent);
   }

第三幕

      Intent myIntent = getIntent(); 
      int intValue = myIntent.getIntExtra("position", 0);

    switch (intValue)
    {
        case 1:values = new String[] { "Android for lerner1","android for learner2" };break;
        case 2:values = new String[] { "Android  for devloper1","android for devloper2" };break;
    }

/*values = new String[] { "iphone for lerner1","iphone for learner2" }      
values = new String[] { "iphone for devloper1","iphone for devloper2} */
}

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,

             android.R.layout.simple_list_item_1, android.R.id.text1, values);

        g1.setAdapter(adapter); 
}

我需要

  • 当用户点击 android 时,使用 switch case 在另一个活动中显示数据
  • 然后显示数据 android Lerner 或 android developers.then 点击 android learner
  • 然后显示 android lerner1 或 android learner2
  • and when select android developer then display android lerner1 or android learner2.

在这里,它仅适用于 android,不适用于 iphone 或 windows。

4

1 回答 1

0

查看链接,它显示了您想要实现的相同目标。

它会帮助你。

谢谢。

于 2013-02-15T06:35:28.017 回答