android listView another horizontal listView
I am looking for any way by which I can place android listView with TextView and another horizontal listView corresponding to that listView.
开发者_JAVA技巧Actually I'm having a List of items and shops corresponding to that item I have sub categories.
And also a shop can have multiple sub categories like it,s different sub categories(child).
The situation to display is just like,
................................................
Eat(TEXT VIew)
Image Image Image (multiple categories in that item) .....
Name Name Name (multiple categories in that item)
............................................................
Use an ArrayAdaptor : look custom ListView on google : (first result) http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/
Basically you need to design the layout of your sublist in XML, then design the layout of your main ListView in XML.
I think you whould use wrap_content
for your sublist, width : fill_parent
for the main list and height : wrap_content
for the main list.
Then you need two classes to hold your required data of each item (one for the main list containing one of your sublist).
Then you create ArrayList and ArrayList (stored in each MyMainItem). Then you'll need to create two class extenting ArrayAdaptor : MainAdapter extends ArrayAdaptor and SecondaryAdapter
In each of your ArrayAdapter you'll need to store the list of items and override the constructor like so :
private ArrayList<MyObj> items = new ArrayList<MyObj>();
public ArticlesAdapter(Context context, int textViewResourceId,
ArrayList<MyObj> items) {
super(context, textViewResourceId, items);
this.items = items;
}
In each adaptor, you'll have to override the method
@Override
public View getView(int position, View convertView, ViewGroup parent)
like shown in the tutorial But don't forget in your MainAdapter to call the setAdaptor() on the subListView. Be careful with the getView method : you are highly to receive a null object, so make sure to test it to avoid NullPointerException
Hope I helped you. This is worth a Bounty :-)
I think you can set in xml!
enter code here
android:divider="@null"
android:dividerheight="10dp"<-- space between items-->
精彩评论