Note that there are some explanatory texts on larger screens.

plurals
  1. POtab, listview and intent
    primarykey
    data
    text
    <p>I have three 2 tab TabA and TabB. TabA displays value its ok. Now in Tab2 i have listview displaying the values. Whenever I click the listitem value that value have to pass to the next activity and new tab have to be created based on that value every time I click the listItem the tab should be generated. My problem is inside the click event of listitem intent = new Intent() is not supported. My code is as follows</p> <pre><code>public class FriendLists extends TabActivity { //Declarations public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.friendtab); connection=XMPPLogic.getInstance().getConnection(); Resources res = getResources(); // Resource object to get Drawables TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; // Reusable TabSpec for each tab Intent intent; // Reusable Intent for each tab lv=(ListView) findViewById(R.id.footerlist); adapter = new ArrayAdapter&lt;String&gt;(this,R.layout.listitems,R.id.list_content, my_own_listarray); lv.setAdapter(adapter); //end of listing friends final AlertDialog.Builder alertbox = new AlertDialog.Builder(this); lv.setOnItemClickListener(new AdapterView.OnItemClickListener(){ @Override public void onItemClick( AdapterView&lt;?&gt; parent, View v, int position, long id){ //problem is here when i try to put intent and pass String S it creates a problem String S=group.get(position).toString(); // spec = tabHost.newTabSpec(S).setIndicator(S, // res.getDrawable(R.drawable.tab_friendlist)) // .setContent(null); // tabHost.addTab(spec); // set the message to display alertbox.setMessage(S).show(); }}); // Create an Intent to launch an Activity for the tab (to be reused) intent = new Intent().setClass(this,Friends.class); // Initialize a TabSpec for each tab and add it to the TabHost spec = tabHost.newTabSpec("friendlist").setIndicator("Friend List", res.getDrawable(R.drawable.tab_friendlist)) .setContent(intent); tabHost.addTab(spec); tabHost.setCurrentTab(0); tabHost.addTab(tabHost.newTabSpec("onlinefriends").setIndicator("Online Friends", res.getDrawable(R.drawable.tab_friendlist)) .setContent(R.id.footerlist)); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload