I'm writing simple filter in Android and want to use ExpandableListAdapter with check boxes.
I have no problem with creating list or checking checkbox. but I really don't know how to remember choices. After closing group and opening again or when I try to open different group checkboxes are changes.
I tried to reading on the net about that but I didn`t find how to solve my problem.
Here is my code:
public class TasksFilterDialog extends Dialog{
private static final String TAG = "Filter Dialog";
private static final String ChildID = "ChildID";
private static final String GroupID = "GroupID";
private boolean[] statusCheck;
ExpandableListView list;
SimpleExpandableListAdapter listAdapter;
public TasksFilterDialog(Context context) {
super(context);
statusCheck = new boolean[Tasks.Status.values().length];
for(int i=0; i<statusCheck.length; i++)
statusCheck[i]=true;
}
#Override
protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "Creating dialog");
this.setContentView(R.layout.tasks_filter);
list = (ExpandableListView)findViewById(R.id.filter_list);
setListAdapter(); // Setting Adapter Values to use on list
list.setAdapter(listAdapter); // Setting creating adapter to list
setOnChildClickListeners();
Log.d(TAG, "Creating dialog successfull");
}
private void setListAdapter() {
Log.d(TAG, "Setting list adapter");
listAdapter = new SimpleExpandableListAdapter(this.getContext(),
getGroups(),
R.layout.tasks_filter_groups_layout,
new String[] {GroupID},
new int[] {R.id.filter_group_text},
getChilds(),
R.layout.tasks_filter_simple_element,
new String[] {ChildID},
new int[] {R.id.filter_simple_element_text});
Log.d(TAG, "Setting list adapter successfull");
}
private List<HashMap<String, String>> getGroups() {
Log.d(TAG, "Adding groups values");
List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
HashMap<String, String> statusMap = new HashMap<String, String>();
statusMap.put(GroupID, "Status");
list.add(statusMap);
HashMap<String, String> usersMap = new HashMap<String, String>();
usersMap.put(GroupID, "Users");
list.add(usersMap);
Log.d(TAG, "Adding groups values successfull");
return list;
}
private List<List<HashMap<String, String>>> getChilds() {
Log.d(TAG, "Adding childs values");
List<List<HashMap<String, String>>> list = new ArrayList<List<HashMap<String, String>>>();
List<HashMap<String, String>> secList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map;
Tasks.Status status[] = Tasks.Status.values();
for(int i=0; i<status.length; i++) {
Log.d(TAG, "Adding child" + status[i].toString());
map = new HashMap<String, String>();
map.put(ChildID, status[i].toString());
secList.add(map);
}
list.add(secList);
list.add(secList);
Log.d(TAG, "Adding childs values succesfull");
return list;
}
private void setOnChildClickListeners() {
list.setOnChildClickListener(new OnChildClickListener() {
#Override
public boolean onChildClick(ExpandableListView list, View v,
int group, int id, long arg4) {
CheckBox cb = (CheckBox) v.findViewById(R.id.filter_simple_element_check);
cb.toggle();
switch(group){
case 0:
if(statusCheck[id])
statusCheck[id]=false;
else
statusCheck[id]=true;
break;
case 1:
//TODO After getting Tasks function
}
return false;
}
});
}
}
It depends on how much you want to engineer it. A Map> would work. The Map takes a position and gives you a set of checked children. To determine if a child is checked or not, call Map.get() on group, and then see if the set contains the id of the child.
If you want to see if the second child of the third group is checked, you could do:
boolean isChecked = yourMap.get(3).contains(2);
To set a child checked:
yourMap.get(groupNum).add(childNum);
To set a child unchecked:
yourMap.get(groupNum).remove(childNum);
You would need to initialize the map to contain empty sets for every group to avoid NPEs, but thats easy to do when you first create the map. I'm sure you could come up with a cleaner way to do this, but its simple and it would work.
Related
I wanted to make a listview with alphabetical adapter so that you can see the letters mapped to each section when fastscrolling. The following works correctly when the listview is initialised. However, if the list changes (e.g. adding or removing rows) the indexer does not seem to update even though a new adapter is created each time. It uses the same set of alphabets as the original list.
private void GenerateListView (final ArrayList<String> listItems) {
try {
listView = (ListView) findViewById(R.id.listView_browser);
// generate section index adapter
AlphabeticalAdapter adapter = new AlphabeticalAdapter(this,
android.R.layout.simple_list_item_1, listItems);
listView.setAdapter(adapter);
// recall scroll position
if (_currPos < listItems.size())
listView.setVerticalScrollbarPosition(_currPos);
} catch (Exception e) {
e.printStackTrace();
}
}
The following is the alphabetical adapter class.
public class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer
{
private HashMap<String, Integer> alphaIndexer;
private String[] sections;
public AlphabeticalAdapter(Context c, int resource, List<String> data)
{
// create ArrayAdapter<String>
super(c, resource, data);
// generate HashMap
alphaIndexer = new HashMap<>();
// generate index
for (int i = 0; i < data.size(); i++)
{
// convert first letter of each entry to upper case
String s = data.get(i).substring(0, 1).toUpperCase();
// map letter with corresponding index
if (!alphaIndexer.containsKey(s))
alphaIndexer.put(s, i);
}
// assign set view of keys in the HashMap
Set<String> sectionLetters = alphaIndexer.keySet();
// generate list from the set view
ArrayList<String> sectionList = new ArrayList<>(sectionLetters);
// sort list alphabetically
Collections.sort(sectionList);
// define and populate string array with the letters
sections = new String[sectionList.size()];
for (int i = 0; i < sectionList.size(); i++)
sections[i] = sectionList.get(i);
}
See this solution Code.
And to update SectionIndexer using filter or any data change override this method. It's work for me.
#Override
public void notifyDataSetInvalidated() {
//write your code
super.notifyDataSetInvalidated();
}
I am writing an android application to view nearby locations using Google places API, my application consists of two activity, the first activity finds the nearby locations, store info about these locations in a HashMap, and displays them on a map.
in the second activity I want to get the names of locations from the HashMap from the first activity and display them in a ListView.
the first activity:
HashMap<String, String> hmPlace;
protected void onPostExecute(List> list){
// Clears all the existing markers
mGoogleMap.clear();
for(int i=0;i<list.size();i++){
// Creating a marker
MarkerOptions markerOptions = new MarkerOptions();
// Getting a place from the places list
//HashMap<String, String>
hmPlace = list.get(i);
// Getting latitude of the place
double lat = Double.parseDouble(hmPlace.get("lat"));
// Getting longitude of the place
double lng = Double.parseDouble(hmPlace.get("lng"));
// Getting name
String name = hmPlace.get("place_name");
// listP[i]=hmPlace.get("place_name");
Log.d("places=",hmPlace.get("place_name"));
// Getting vicinity
String vicinity = hmPlace.get("vicinity");
LatLng latLng = new LatLng(lat, lng);
// Setting the position for the marker
markerOptions.position(latLng);
// Setting the title for the marker.
//This will be displayed on taping the marker
markerOptions.title(name + " : " + vicinity);
// Placing a marker on the touched position
Marker m = mGoogleMap.addMarker(markerOptions);
// Linking Marker id and place reference
mMarkerPlaceLink.put(m.getId(), hmPlace.get("reference"));
}
}
I passed the HashMap like this:
intent = new Intent(getApplicationContext(), List_airports.class);
intent.putExtra("com.example.dashboard_our.hmPlace",hmPlace);
startActivity(intent);
I get the values from the HashMap in the second activity :
final ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < places1.size(); ++i) {
list.addAll(places1.values());
}
where places1 is HashMap I got from another activity :
HashMap<String, String> places1=(HashMap<String, String>) extras.getSerializable("com.example.dashboard_our.hmPlace");
but It only brings the first element and print it many times
this is the rest of the second activity:
final StableArrayAdapter adapter = new StableArrayAdapter(this,
android.R.layout.simple_list_item_1, list);
listview.setAdapter(adapter);
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, final View view,
int position, long id) {
final String item = (String) parent.getItemAtPosition(position);
view.animate().setDuration(2000).alpha(0)
.withEndAction(new Runnable() {
#Override
public void run() {
list.remove(item);
adapter.notifyDataSetChanged();
view.setAlpha(1);
}
});
}
});
}
private class StableArrayAdapter extends ArrayAdapter<String> {
HashMap<String, Integer> mIdMap = new HashMap<String, Integer>();
public StableArrayAdapter(Context context, int textViewResourceId,
List<String> objects) {
super(context, textViewResourceId, objects);
for (int i = 0; i < objects.size(); ++i) {
mIdMap.put(objects.get(i), i);
}
}
#Override
public long getItemId(int position) {
String item = getItem(position);
return mIdMap.get(item);
}
#Override
public boolean hasStableIds() {
return true;
}
}
make one datacontroller class like this
public class DataController {
private static DataController ref;
public static DataController getInstance()
{
if(ref==null)
ref = new DataController();
return ref;
}
public HashMap hashmap_datacntrlr = new HashMap();
}
from this you get one singlton class which has only one instance in whole app now u just make any datatype which you want to use and save like i mention hashmap now just do this where u get your DATA and save in data controller like this
DataController datacntrl;
in on create
datacntrl = DataController.getInstance();
and excess hasmap like datacntrl.hashmap_datacntrlr = PASTE YOUR DATA WHICH IS MUST HAVE SAME DATATYPE;
now in your target class again make datacontoller instance and excess and get datacntrl.hashmap_datacntrlr at where u want to show your data
its call caching some time when we use old data and not trigger again and again from server :)
may be it will help u to achieve your target
BEST OF LUCK DUDE :)
I have an app that loads the traffic report from a server and shows it in a timeline (like twitter), the app is configured to load the data from the server every 10 seconds using this code:
#Override
public void onResume() {
super.onResume();
autoUpdate = new Timer();
autoUpdate.schedule(new TimerTask() {
#Override
public void run() {
runOnUiThread(new Runnable() {
public void run() {
new DownloadJSON2().execute(); // this is the class that downloads the data from the server.
}
});
}
}, 0, 10000); // updates each 10 secs
}
#Override
public void onPause() {
autoUpdate.cancel();
super.onPause();
}
The problem is that if I scroll down the list and I'm reading the older posts, the list refreshes and send me to the top of it. I want to download that data like ajax and append it to the top. Or just to tell me that is X new reports and a button to show it.
How can I acomplish this?
BTW I'm extremely new to android programming.
Thanks in advance.
EDIT: Thanks to Vasily Sochinsky i've added the following:
public class DownloadJSON extends AsyncTask<Void, Void, Void> {
#Override
protected void onPreExecute() {
super.onPreExecute();
// Create a progressdialog
mProgressDialog = new ProgressDialog(MainActivity.this);
// Set progressdialog title
mProgressDialog.setTitle("Cargando reportes en tiempo real");
// Set progressdialog message
mProgressDialog.setMessage("Por favor espere");
mProgressDialog.setIndeterminate(false);
// Show progressdialog
mProgressDialog.show();
}
#Override
protected Void doInBackground(Void... params) {
// Create an array
arraylist = new ArrayList<HashMap<String, String>>();
// Retrieve JSON Objects from the given URL address
jsonobject = JSONfunctions
.getJSONfromURL("http://server.com/timeline.php");
try {
// Locate the array name in JSON
jsonarray = jsonobject.getJSONArray("datos");
for (int i = 0; i < jsonarray.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
jsonobject = jsonarray.getJSONObject(i);
// Retrive JSON Objects
// jsonobject1 = jsonobject.getJSONObject("contenido");
map.put("imagen", jsonobject.getString("imagen"));
map.put("quien", jsonobject.getString("quien"));
map.put("fecha", jsonobject.getString("fecha"));
map.put("reporte", jsonobject.getString("reporte"));
// map.put("imgs", jsonobject1.getString("imgs"));
// map.put("video", jsonobject1.getString("video"));
// Set the JSON Objects into the array
arraylist.add(map);
}
} catch (JSONException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}
#Override
protected void onPostExecute(Void args) {
// Locate the listview in listview_main.xml
listview = (ListView) findViewById(R.id.listview);
// Pass the results into ListViewAdapter.java
adapter = new ListViewAdapter(MainActivity.this, arraylist);
// Set the adapter to the ListView
listview.setAdapter(adapter);
adapter.notifyDataSetChanged();
// Close the progressdialog
mProgressDialog.dismiss();
}
}
But the listview is not updating with the new data, how can i achieve this?
EDIT 2: Thanks to cogentapps that gave me a solution, but i still can not add it to the code, where should i add it?
I've tried this but eclipse shows many errors:
protected void onPostExecute(Void args) {
// Locate the listview in listview_main.xml
listview = (ListView) findViewById(R.id.listview);
// Pass the results into ListViewAdapter.java
adapter = new ListViewAdapter(MainActivity.this, arraylist);
// Set the adapter to the ListView
adapter.addAll();
listview.notifyDataSetChanged();
// Close the progressdialog
mProgressDialog.dismiss();
}
This is the code from my ListViewAdapter, where should i add the adapter.add()?
public class ListViewAdapter extends BaseAdapter {
// Declare Variables
Context context;
LayoutInflater inflater;
ArrayList<HashMap<String, String>> data;
ImageLoader imageLoader;
HashMap<String, String> resultp = new HashMap<String, String>();
String coment;
public String img;
public int imga;
public ListViewAdapter(Context context,
ArrayList<HashMap<String, String>> arraylist) {
this.context = context;
data = arraylist;
imageLoader = new ImageLoader(context);
}
#Override
public int getCount() {
return data.size();
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
public View getView(final int position, View convertView, ViewGroup parent) {
// Declare Variables
TextView quien;
ImageView imagen;
TextView reporte;
TextView fecha;
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.listview_item, parent, false);
// Get the position
resultp = data.get(position);
// Locate the TextViews in listview_item.xml
// Locate the ImageView in listview_item.xml
imagen = (ImageView) itemView.findViewById(R.id.imagen);
fecha = (TextView) itemView.findViewById(R.id.fecha);
quien = (TextView) itemView.findViewById(R.id.quien);
reporte = (TextView) itemView.findViewById(R.id.reporte);
// Capture position and set results to the TextViews
// Capture position and set results to the ImageView
// Passes flag images URL into ImageLoader.class
imageLoader.DisplayImage(resultp.get(MainActivity.IMAGEN), imagen);
fecha.setText(resultp.get(MainActivity.FECHA));
reporte.setText(resultp.get(MainActivity.REPORTE));
quien.setText(resultp.get(MainActivity.QUIEN));
// Capture ListView item click
/*
itemView.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// Get the position
resultp = data.get(position);
Intent intent = new Intent(context, SingleItemView.class);
// Pass all data rank
intent.putExtra("imagen", resultp.get(MainActivity.IMAGEN));
intent.putExtra("quien", resultp.get(MainActivity.QUIEN));
intent.putExtra("fecha", resultp.get(MainActivity.FECHA));
// Start SingleItemView Class
context.startActivity(intent);
}
});
*/
return itemView;
}
}
Take a look at the answer to this question for an explanation / example of how to maintain scroll position after adding items to a list: Retaining position in ListView after calling notifyDataSetChanged
Basically, you make a note of the position and scroll offset of the first visible item in the list before adding new data. Then afterwards, you restore the previous position and scroll offset.
However, because you're adding new items at the top of the list, the position returned by getFirstVisiblePosition() may refer to a different item after refreshing. The item that was at position 0 before refreshing may now be position 10. To fix that, you need to determine the number of new items returned by timeline.php and add it to index, like this:
mList.setSelectionFromTop(index + newItemCount, top);
You could probably determine which items are new by comparing the date field.
(By the way, if timeline.php only returns the most recent set of items, you could run into trouble if the user has scrolled to an older item which is no longer returned by timeline.php. After setting the new data, the old item will no longer be present, so you won't be able to scroll to it.
To fix that, you could keep the old ArrayList around and only add new items to it in doInBackground(). And call notifyDataSetChanged() in doInBackground(). That way, the adapter will still have access to older items.)
ListViews have always been my weak point and right now I am practicing putting a Listview, within a Listview. Anyway, I first call my ListView at the start of my program and it loads it with an array saved in my strings.xml:
String[] departments = getResources().getStringArray(
R.array.departments_array);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item,
departments));
setContentView(R.layout.main);
ListView lv = getListView();
lv.setTextFilterEnabled(true);
What I want to do is update this ListView with a new array of values each time a list item is clicked. The reason why I am trying to do it this way is because I plan on having 27 different arrays with different values for each position, and I feel it would be lighter on my resources if instead of making a ListView for each array of items, I would update this one ListView. I know I am probably not doing this the most efficient way, but if there is another way of implementing my idea please tell me.
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, show a toast with the TextView text
switch (position) {
case 0:
try {
//It is here that i dont know what to do, I was going to call
//the Listview the same way i did previously using my setlistadapter,
//but i kept getting errors about the code being undefined
String[] listitems1 = getResources().getStringArray(
R.array.items_array);
} catch (ClassCastException e) {
Toast.makeText(getApplicationContext(), "Error",
Toast.LENGTH_SHORT).show();
}
break;
case 1:
try {
//The listview will be changed again here
} catch (ClassCastException e) {
Toast.makeText(getApplicationContext(), "Error",
Toast.LENGTH_SHORT).show();
}
break;
}
};
});
Have you thought of using a BaseAdapter and setting it as the list adapter
http://developer.android.com/reference/android/widget/BaseAdapter.html
Your approach is wrong( if I understand what are you doing). Instead of replacing the adapter of the ListView every time the user clicks(and simply setting a new adapter should work) a element in the initial list you should start a new activity passing the clicked position and in your new activity set the adapter on a ListView with the correct array based on that position.
A small example:
Main class:
/**
* The main class with the initial 27 items array.
*/
public class Class1 extends ListActivity {
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// start the second activity that will show our array depending on the
// position clicked
Intent i = new Intent(this, Class2.class);
// put the position in the Intent so we can know in the other activity
// what array to load.
i.putExtra("pos", position);
startActivity(i);
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// I just used a simple array of 2 items, you'll load your 27 items
// array
String[] items = { "1", "2" };
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items));
}
}
Secondary activity that will show the array based on the previously selected position:
public class Class2 extends ListActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// get the Intent that started the activity
Intent i = getIntent();
// find out what position did that other activity send to us.
int position = i.getIntExtra("pos", -1);
// load the ListView with an adapter based on the array that you
// want(according to that position)
if (position == 0) {
// the first element in the main list
String[] items = getResources().getStringArray(R.array.a1);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items));
} else if (position == 1) {
// the second element in the main list
String[] items = getResources().getStringArray(R.array.a2);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items));
} else {
// etc
}
}
}
Luksprog's answer is indeed correct, and it is very useful for lists many levels deep (you do not put limits, just keep spawning new activity instances with the proper list loaded)
BUT
If your list isn't more than 2 levels deep you can use ExpandableListActivity instead of ListActivity which is basically an enhanced version of the single-level list you're using which natively handle group collapsing/expanding and therefore you do not need the spawn of a new activity for each sublevel.
again note that this approach works only for lists which do not go deeper than 2 levels
ExpandableListActivity documentation
ExpandableListView documentation
ExpandableListAdapter documentation - you should be fine with the BaseExpandableListAdapter implementation
And here you have some nice example from Google itself:
public class ExpandableList3 extends ExpandableListActivity {
private static final String NAME = "NAME";
private static final String IS_EVEN = "IS_EVEN";
private ExpandableListAdapter mAdapter;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
for (int i = 0; i < 20; i++) {
Map<String, String> curGroupMap = new HashMap<String, String>();
groupData.add(curGroupMap);
curGroupMap.put(NAME, "Group " + i);
curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");
//filling with dummy data...
List<Map<String, String>> children = new ArrayList<Map<String, String>>();
for (int j = 0; j < 15; j++) {
Map<String, String> curChildMap = new HashMap<String, String>();
children.add(curChildMap);
curChildMap.put(NAME, "Child " + j);
curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
}
childData.add(children);
}
// Set up our adapter
mAdapter = new SimpleExpandableListAdapter(
this,
groupData,
android.R.layout.simple_expandable_list_item_1,
new String[] { NAME, IS_EVEN },
new int[] { android.R.id.text1, android.R.id.text2 },
childData,
android.R.layout.simple_expandable_list_item_2,
new String[] { NAME, IS_EVEN },
new int[] { android.R.id.text1, android.R.id.text2 }
);
setListAdapter(mAdapter);
}
}
I have an expandable list in android and I can fill it with string easily but now I want to add a drawable on each row of the list (a different one on each row), what's the easiest way to do this with the code I already have? Thanks.
public class Physical extends ExpandableListActivity {
public static final int GROUPS = 1;
public SimpleExpandableListAdapter expListAdapter;
private boolean expanded = true;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.phys_sub);
String [] cats = { "phy1", "phys2" };
List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
for (int i = 0; i < GROUPS; i++) {
Map<String, String> curGroupMap = new HashMap<String, String>();
groupData.add(curGroupMap);
curGroupMap.put( "group", "Categories" );
List<Map<String, String>> children = new ArrayList<Map<String, String>>();
for( int n = 0 ; n < cats.length ; n++ ) {
Map<String, String> curChildMap = new HashMap<String, String>();
curChildMap.put( "child", cats[n] );
children.add(curChildMap);
}
childData.add(children);
}
expListAdapter =
new SimpleExpandableListAdapter(
/* context */
this,
/* creates Group list */
groupData,
/*Group item layout XML */
R.layout.group_row,
/* the key of each group element (not child's) */
new String[] { "group" },
/* data under the key goes into this TextView */
new int[] { R.id.group_text },
/* creates Child List (sub-level entries) */
childData,
/* layout for children in list */
R.layout.child_sub,
/* the key of each child element */
new String[] { "child" },
/* data under the child keys go into this textView */
new int[] { R.id.child_text }
);
/* sets up and initializes the adapter for the list */
setListAdapter(expListAdapter);
getExpandableListView().setOnGroupExpandListener( new OnGroupExpandListener() {
public void onGroupExpand(int groupPosition) {
expanded = true;
}
});
getExpandableListView().setOnGroupCollapseListener( new OnGroupCollapseListener() {
public void onGroupCollapse(int groupPosition) {
expanded = false;
}
});
if (expanded != false ) {
getExpandableListView().expandGroup(0);
}
}
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, final int childPosition, long id) {
switch (childPosition) {
case 0:
Intent spine_plus_intent = new Intent(Physical.this, SpinePlus.class);
startActivity(spine_plus_intent);
finish();
break;
}
return true;
}
}
you'd define a custom expandable list adapter and redefine the getchildview / getgroupview.
From there you have 2 routes to follow: one, you can programmatically add the imageviews into the child/group view (i'd discourage you from this approach), or you define an xml layout file for the child/group view and inflate it (and possibly edit the content dynamically)
Simple adapters aren't flexible enough to achieve good results. Expecially when you want custom views for their elements. (Not to mention scalability: always project and code keeping in mind that your requirements may enlarge in the future and a flexible base allows more freedom and prevents you from scratching too much code)