I tried to implement multiple gridView within a scrollview so that all girdview has only one scrollbar.
I used two gridView.
My layout is like that:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.example.ExpandableHeightGridView
android:id="#+id/gridView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:horizontalSpacing="2dp"
android:isScrollContainer="false"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="20dp" />
<com.example.ExpandableHeightGridView
android:id="#+id/gridView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:horizontalSpacing="2dp"
android:isScrollContainer="false"
android:numColumns="1"
android:stretchMode="columnWidth"
android:verticalSpacing="20dp" />
</LinearLayout>
</ScrollView>
I used This like for "ExpandableHeightGridView"
and in main activity i used this:
final ExpandableHeightGridView gView1 = new ExpandableHeightGridView(this);
gView1.setNumColumns(2);
ArrayList<HashMap<String, String>> list_of_wordmeanings = new ArrayList<HashMap<String, String>>();
Cursor mCursor = mDbHelper.getWord(value_of_category_id);
for (int i = 0; i < mCursor.getCount(); i++)
{
mCursor.moveToPosition(i);
HashMap<String, String> hm = new HashMap<String, String>();
String column1data = mCursor.getString(0).toString();
String column2data = mCursor.getString(1).toString();
String column3data = mCursor.getString(2).toString();
hm.put("key_word",column1data);
hm.put("key_meaning",column2data);
hm.put("key_translitaration",column3data);
list_of_wordmeanings.add(hm);
}
// Keys used in Hashmap
String[] from = { "key_word","key_meaning","key_translitaration" };
int[] to = { R.id.txt1,R.id.txt2,R.id.txt3}; // Instantiating an adapter to store each items
// R.layout.listview_layout defines the layout of each item
SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), list_of_wordmeanings, R.layout.grid_layout, from, to);
// Setting the adapter to the listView
gView1.setAdapter(adapter);
gView1.setExpanded(true);
gView1.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
// TODO Auto-generated method stub
HashMap<String, String> hash = new HashMap<String, String>();
hash=(HashMap<String, String>) gView1.getItemAtPosition(position);
String english_word=hash.get("key_word");
String native_word=hash.get("key_meaning");
// Show Alert
Toast.makeText(getApplicationContext(),
" gridViewValue : "+native_word , Toast.LENGTH_LONG)
.show();
}
});
It doesn't work properly.
In GridView2, you restricted with Number of Columns as 1. Check it.
The purpose of GridView is to implement multiple columns.
Related
I got a problem with ListView.My activity inherit ListView that has an android:id="#android:id/list" value set.I searched solution, but it did not work.
This is my configuration file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
android:scrollbars="vertical"></ListView>
</LinearLayout>
My OnCreate is here:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_view_demo);
listView = getListView();
ArrayList<HashMap<String, String>> list =
new ArrayList<HashMap<String, String>>();
HashMap<String, String> map1 = new HashMap<String,String>();
HashMap<String, String> map2 = new HashMap<String,String>();
HashMap<String, String> map3 = new HashMap<String,String>();
map1.put("user_ip", "user_name");
map1.put("192.168.25.3", "Maple");
map2.put("user_ip", "user_name");
map2.put("192.168.34.3", "Sonny");
map3.put("user_ip", "user_name");
map3.put("192.168.25.12", "Eric");
list.add(map1);
list.add(map2);
list.add(map3);
SimpleAdapter simpleAdapter = new SimpleAdapter(this, list,
R.layout.user,
new String[]{"user_ip", "user_name"},
new int[]{R.id.user_ip, R.id.user_name});
this.setListAdapter(simpleAdapter);
}
Anyone help?
getListView() is specific method for ListFragment/ListActivity do you use one of those?
Remove:
listView = getListView();
The way you are initializing listView is wrong.
Change,
private ListView listView = getListView();
to
ListView listView = (ListView) findViewById(R.id.list);
And if you are setting the contentView, you don't need to extend your activity to ListActivity
I have a listview with three items in it. color_id, color_name, and color_count
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="#+id/color_id"/>
<TextView android:id="#+id/color_name"/>
<TextView android:id="#+id/color_count"/>
</LinearLayout>
I load data from the server into my list. Here I'm adding data to the list manually for demonstration:
ArrayList<HashMap<String, String>> colorsList = new ArrayList();
HashMap<String, String> map = new HashMap();
map.put("id", "1");
map.put("color_name", "red");
map.put("color_count", "10");
colorsList.add(map);
map = new HashMap();
map.put("id", "2");
map.put("color_name","yellow"):
map.put("color_count","15");
colorsList.add(map);
ListAdapter adapter = new SimpleAdapter(
MyActivity.this, colorsList,
R.layout.list_item_colors, new String[] {"id",
"color_name","color_count"}, new int[] {
R.id.color_id, R.id.color_name, R.id.color_count});
setListAdapter(adapter);
Question
All this is working fine for me. However, for other reasons I want to part ways with SimpleAdapter and instead use ArrayAdapter However, with ArrayAdapter
I'm not sure how to set the three items I have : color_id, color_name, and color_count
You will need to create your custom ArrayAdapter and ovveride getView() method , this method which called each time you create item in list view and in it you will inflate your layout (which contain textviews )and attach its data
there is good tutorial about ListView and custom one
http://www.vogella.com/tutorials/AndroidListView/article.html
and feel free to feed me back in any thing not obvious for you
You can use SimpleAdapter.This is my demo.
The MainActivity.java:
public class MainActivity extends Activity{
private ArrayList<HashMap<String, String>> colorsList;
private ListView list;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
list=(ListView)findViewById(R.id.listcolor);
colorsList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
map.put("id", "1");
map.put("color_name", "red");
map.put("color_count", "10");
colorsList.add(map);
map = new HashMap<String, String>();
map.put("id", "2");
map.put("color_name","yellow");
map.put("color_count","15");
colorsList.add(map);
SimpleAdapter adapter=new SimpleAdapter(this,colorsList,R.layout.list_item_colors,
new String[] {"id","color_name","color_count"},
new int[] {R.id.color_id, R.id.color_name, R.id.color_count});
list.setAdapter(adapter);
}
}
the XMl:
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ListView
android:id="#+id/listcolor"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
the list_item_colors.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/color_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/color_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/color_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
I am retrieving data from sqlite and showing it in a listview using simpleadapter.I don't have any issues regarding Layouts.Still just for your reference :
list_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<!-- Name Label -->
<TextView
android:id="#+id/subject"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:paddingTop="6dip"
android:textColor="#421fc4"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/day"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:textStyle="bold" />
<TextView
android:id="#+id/slot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:textColorHighlight="#782086"
android:textStyle="bold" />
<TextView
android:id="#+id/instructor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:textColor="#782086"
android:textStyle="bold" />
</LinearLayout>
I am having problem somewhere in the following code snippet.I tried to retrieve the data from sqlite using normal listview and it worked perfect.But when i used this code snippet for custom listview using SimpleAdapter i get only the last row of the result of the query.That last row's data gets repeated 8 times in the listview as there are 8 rows in the result of the query.
HashMap<String, String> hashMap = new HashMap<String, String>();
ArrayList<HashMap<String, String>> Timetablelist;
//c being the cursor
if (c.moveToFirst()) {
do {
String subject = c.getString(c.getColumnIndex(dba.KEY_SUBJECT));
String day = c.getString(c.getColumnIndex(dba.KEY_DAY));
String slot = c.getString(c.getColumnIndex(dba.KEY_SLOT));
String instructor = c.getString(c.getColumnIndex(dba.KEY_INSTRUCTOR_NAME));
// adding each child node to HashMap key => value
hashMap.put("Subject", subject);
hashMap.put("Day", day);
hashMap.put("Slot", slot);
hashMap.put("Instructor", instructor);
Timetablelist.add(hashMap);
ListAdapter adapter = new SimpleAdapter(
this, Timetablelist,R.layout.list_item, new String[] { "Subject", "Day",
"Slot","Instructor" }, new int[] { R.id.subject,
R.id.day, R.id.slot,R.id.instructor });
setListAdapter(adapter);
}while (c.moveToNext());
}
P.S : I was able to retrieve data using normal listview.So database and other layouts are working fine.
Move the below out of do While
ListAdapter adapter = new SimpleAdapter(
this, Timetablelist,R.layout.list_item, new String[] { "Subject", "Day",
"Slot","Instructor" }, new int[] { R.id.subject,
R.id.day, R.id.slot,R.id.instructor });
setListAdapter(adapter);
You get the data from database and you can populate Timetablelist in the do while. But there is no need to initialize adapter everytime and setListAdapter.
Edit:
HashMap<String, String> hashMap ;
ArrayList<HashMap<String, String>> Timetablelist = new ArrayList<HashMap<String,String>>();
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
String subject = c.getString(c.getColumnIndex(dba.KEY_SUBJECT));
String day = c.getString(c.getColumnIndex(dba.KEY_DAY));
String slot = c.getString(c.getColumnIndex(dba.KEY_SLOT));
String instructor = c.getString(c.getColumnIndex(dba.KEY_INSTRUCTOR_NAME));
// adding each child node to HashMap key => value
hashMap = new HashMap<String, String>();
hashMap.put("Subject", subject);
hashMap.put("Day", day);
hashMap.put("Slot", slot);
hashMap.put("Instructor", instructor);
Timetablelist.add(hashMap);
}
ListAdapter adapter = new SimpleAdapter(
this, Timetablelist,R.layout.list_item, new String[] { "Subject", "Day",
"Slot","Instructor" }, new int[] { R.id.subject,
R.id.day, R.id.slot,R.id.instructor });
setListAdapter(adapter);
I have a mutlicolumn list in which I also want one of the columns to include a drop down spinner.
My main.xml is: -
<!-- main.xml -->
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/SCHEDULE" android:layout_width="wrap_content" android:layout_height="wrap_content">
</ListView>
My row xml is
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="4dip"
android:paddingBottom="6dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="#+id/LEVEL_CELL"
android:layout_width="50dip"
android:layout_height="wrap_content"/>
<TextView android:id="#+id/ACTION_CELL"
android:layout_width="50dip"
android:layout_height="wrap_content"/>
<Spinner
android:id="#+id/fromTables"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Here is my logic: -
super.onCreate(savedInstanceState);
setContentView(R.layout.row);
fromTablesSpinner = (Spinner) findViewById(R.id.fromTables);
setContentView(R.layout.main);
ListView list = (ListView) findViewById(R.id.SCHEDULE);
ArrayList<String> tables = new ArrayList<String>();
tables.add("MARA");
tables.add("MARC");
tables.add("MARD");
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
map.put("level", "1");
map.put("action", "INNER JOIN");
map.put("tables", "MARA");
map.put("tables", "MARC");
mylist.add(map);
map = new HashMap<String, String>();
map.put("level", "2");
map.put("action", "OUTER JOIN");
map.put("tables", "MARA");
map.put("tables", "MARC");
mylist.add(map);
SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, R.layout.row,
new String[] { "level", "action" }, new int[] {
R.id.LEVEL_CELL, R.id.ACTION_CELL });
list.setAdapter(mSchedule);
}
The use of SimpleAdapter does not allow me to bind to a spinner view.
Any help is much appreciated.
Thanks
Martin
You are trying two complicated things at once. Follow these steps:
1) Learn to build a custom adapter which shows more than one type of views in a single list. This will help you to show a spinner in the list.
Links : http://www.ezzylearning.com/tutorial.aspx?tid=1763429
Android ListView with different layouts for each row
2) Learn to handle different view and listeners.
Links: Listview with TextView and Button. RowId of the clicked button (btnButtonOFF.setOnClickListener(new ItemClickListener(cur.getInt(idRow)));)
3) Use Multiple ListViews like you are using.
I have a 2-column row layout that looks like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="4dip"
android:paddingBottom="6dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:textSize="13sp">
<TextView android:id="#+id/TRAIN_CELL"
android:layout_width="275dip"
android:layout_height="wrap_content"/>
<ImageView android:id="#+id/TO_CELL"
android:layout_width="25dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:src="#drawable/arrow_button"/>
</LinearLayout>
And once I fetch items from the database, I display them in the left column, and in the right column I want to have a little image with an arrow signifying that it is a clickable item. But I am not sure how to make the image render. Here is how I currently populate that list:
I have these two variables:
private List<HashMap<String, String>> fillMaps;
private SimpleAdapter adapter;
At first I set them up like this:
list = (ListView) findViewById(android.R.id.list);
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
//HashMap<String, String> map = new HashMap<String, String>();
// My data
fillMaps = new ArrayList<HashMap<String, String>>();
adapter = new SimpleAdapter(this, fillMaps, R.layout.questions_list,
new String[] {"train", "to"},
new int[] {R.id.TRAIN_CELL, R.id.TO_CELL});
// This was the middle item R.id.FROM_CELL,
list.setAdapter(adapter);
list.setTextFilterEnabled(true);
and when the data comes back from the server, I populate the list like this:
if ( obj != null )
{
questions.clear();
for ( int i = 0; i < obj.length(); i++ )
{
HashMap<String, String> map = new HashMap<String, String>();
JSONObject o = obj.getJSONObject(i);
question_id = o.getString("question_id");
question = o.getString("question");
question_by_member_id = o.getString("member_id");
Question q = new Question ( );
q.setQuestion( question );
q.setQuestionId( question_id );
q.setQuestionByMemberId(question_by_member_id);
map.put("train", question);
//map.put("from", ">");
//map.put("to", ">");
fillMaps.add(map);
questions.add( q );
}
adapter.notifyDataSetChanged();
}
But I am not getting the image to render. I think part of the problem is that I am using Strings as the data that the list expects, but I am not sure how to handle this with the images. The image is always the same image by the way.
Thanks!! :)
Is this what you want?
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="4dip"
android:paddingBottom="6dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:textSize="13sp">
<TextView android:id="#+id/TRAIN_CELL"
android:layout_width="275dip"
android:layout_height="wrap_content"/>
<ImageView android:id="#+id/TO_CELL"
android:layout_width="25dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:src="#drawable/arrow_button"/>
</LinearLayout>
Addition
(Sorry, sometimes I miss notifications when they pile up over night. I believe you should be able to read messages / remove notifications here on Stack Overflow one by one or all at once, like an inbox...)
Anyway, if TO_CELL's image is always going to be the same, simply set the image in the XML only. Change your SimpleAdapter to this:
adapter = new SimpleAdapter(this, fillMaps, R.layout.questions_list,
new String[] {"train"},
new int[] {R.id.TRAIN_CELL});
Now your adapter only handles one string, you can simplify it to an ArrayAdapter (if you want.)
Simplified Example
You can also display one TextView and display a small "next" arrow like so:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="#android:drawable/ic_media_play"
android:padding="10sp"
android:textAppearance="?android:attr/textAppearanceMedium" />
(A LinearLayout and separate ImageView is not strictly necessary. I saved this as list_item.xml.)
Here is a simple preview, understand that I left a lot of the non-critical lines out to not be repetitive:
public class Example extends Activity {
ArrayAdapter<String> adapter;
List<String> list = new ArrayList<String>();
ListView listView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
adapter = new ArrayAdapter<String>(this, R.layout.list_item, R.id.text, list);
listView = (ListView) findViewById(R.id.list);
listView.setAdapter(adapter);
updateList();
}
public void updateList() {
...
if ( obj != null ) {
questions.clear();
list.clear();
for ( int i = 0; i < obj.length(); i++ ) {
JSONObject o = obj.getJSONObject(i);
...
question = o.getString("question");
list.add(question);
}
adapter.notifyDataSetChanged();
}
}
}
Hope this helps!
I believe the easiest way is instead of using a SimpleAdapter try extending the ArrayAdapter for your needs. You can override the getView() method and populate your list the way you need!
There are a few examples here, here and here.
EDIT
First, you need a few modifications in your xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="4dip"
android:paddingBottom="6dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:textSize="13sp">
<TextView android:id="#+id/TRAIN_CELL"
android:layout_width="275dip"
android:layout_height="wrap_content"/>
<ImageView android:id="#+id/TO_CELL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#fff"/>
</LinearLayout>
In the following code I used a ArrayList of Strings for simplicity. You will have to replace that with a list of whatever object you are using to populate your list. (Question maybe?)
Create an ExtendedAdapter and override the getView() method to do what you intend. This will create a TextView and a ImageView on each row of the list, populate the TextView with the items in your ArrayList items and show the image if the item is clickable. (You have to do the verification by yourself but shouldn't be hard to figure it out)
public class ExtendedAdapter extends BaseAdapter {
public static final String TAG = "TodoAdapter";
private Context mContext;
private int layoutResource;
private boolean clickable = false;
private List<String> items; // you can replace this list with whathever you need
// for simplicity i'm assuming you already have the strings
// you need for the textviews
public ExtendedAdapter(Context context, int textViewResourceId,
List<String> items) {
this.items = items;
this.mContext = context;
this.layoutResource = textViewResourceId;
}
public int getCount() {
return items.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(layoutResource, null);
}
ImageView arrow = (ImageView) v.findViewById(R.id.TO_CELL);
TextView text = (TextView) v.findViewById(R.id.TRAIN_CELL);
text.setText(items.get(position));
if (clickable) // here you have to do your check if it's clickable or not
arrow.setBackgroundResource(R.drawable.ic_launcher);
return v;
}
}
And in your activity, just set the list adapter
public class MainActivity extends Activity {
ListView yourList;
ArrayList<String> itemList = new ArrayList<String>();
ExtendedAdapter adapter;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
yourList = (ListView) findViewById(R.id.yourList);
adapter = new ExtendedAdapter(this, R.layout.row_layout, itemList);
yourList.setAdapter(adapter);
updateItems();
}
public void updateItems(){
//dummy method, you should fetch your data and populate your array in a separate thread
//or something
itemList.add("Text 1");
itemList.add("Text 2");
itemList.add("Text 3");
itemList.add("Text 4");
itemList.add("Text 5");
itemList.add("Text 6");
adapter.notifyDataSetChanged();
}
}
That's how you create a list with text and image.
Good luck!
I think you should customize the list adapter and it will be easy this way.
The problem is with Layout and with the Simple adpater.
1.do not use linearLayout android:textSize="13sp" use it for TextView,
you can use below code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="6dip"
android:paddingTop="4dip" >
<TextView
android:id="#+id/TRAIN_CELL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:text="try out by yourself..."
android:textSize="13sp" />
<ImageView
android:id="#+id/TO_CELL"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".05"
android:gravity="center"
android:src="#android:drawable/arrow_down_float" />
</LinearLayout>
2.The problem is in SimpleAdapter use
adapter = new SimpleAdapter(this, fillMaps, R.layout.questions_list,
new String[] {"train"},
new int[] {R.id.TRAIN_CELL});