• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Expanding a list view

bscarl88

Lurker
I have a tabhost layout with a list in each tab. I am trying to make a listview in a listview like the default music player on the droid, or when clicking on a listview bring up a menu with a list of options (about 7) to choose from. I'm really trying for the former but I can't find anyway to do it, I've tried onListItemClick going to another activity where I will define another list, but it won't work because of errors that I cannot seem to fix to get it working properly.

Code:
	@Override
	public void onCreate(Bundle savedInstanceState) 
	{
	  final String[] CDExplorer_tabs = new String[] {"item1", "item2", "item3", "item4", "item5"};
	  super.onCreate(savedInstanceState);

	  setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, CDExplorer_tabs));

	  ListView lv = getListView();
	  lv.setTextFilterEnabled(true);
	  registerForContextMenu(lv);
	  public void onListItemClick( ListView parent, View v, int position, long id) 
	  {
		  final Intent i = new Intent(this, CDETabs.class);
		  startActivity(i);
	  }

	}
}

any ideas?
 
I'd say, first things first, take your onListItemClick method out of your onCreate method to override the method in your ListActivity class.
 
That helped me fix the errors! thanks! Now I can't find any tutorials on it so I have a couple more questions sadly. Is there any info on how to open the new list under its appropriate list item (like the droid music player)? Should I create a new list_item layout to reference for the new list? And do I have to create a new class for each item in the new list in a new java file?

Code:
public class AlbumTab extends ListActivity
{
	@Override
	public void onCreate(Bundle savedInstanceState) 
	{
	  final String[] CDExplorer_tabs = new String[] {"item1", "item2", "item3", "item4"};
	  super.onCreate(savedInstanceState);

	  setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, CDExplorer_tabs));

	  ListView lv = getListView();
	  lv.setTextFilterEnabled(true);
	  registerForContextMenu(lv);
	}
	@Override
    public void onListItemClick(ListView lv, View v, int position, long id) 
    {
  	  final Intent i = new Intent(this, CDETabs.class);
  	  startActivity(i);
    }
}

here is the current list_layout that it references

HTML:
<?xml version="1.0" encoding="utf-8"?>
<TextView
		
		xmlns:android="http://schemas.android.com/apk/res/android"
	    android:layout_width="fill_parent"
	    android:layout_height="fill_parent"
	    android:padding="10dp"
	    android:textSize="16sp" >
</TextView>
 
Back
Top Bottom