我有一个像这样的 2 列列表布局:
<?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_marginLeft="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="@+id/TRAIN_CELL"
android:layout_width="275dip"
android:layout_height="wrap_content"
android:textSize="16sp"/>
<TextView android:id="@+id/TO_CELL"
android:layout_width="25dip"
android:textSize="20sp"
android:textStyle="bold"
android:gravity="center"
android:textColor="@color/light_best_blue"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
但是这行: android:layout_marginLeft="10dp" 不会产生和增加空间的效果。此外,屏幕本身有一个左边距,但列表也没有响应。
有没有办法确保屏幕左侧有间距?
谢谢!
这是代码:
private List<HashMap<String, String>> fillMaps;
private SimpleAdapter adapter;
ListView list = null;
list = (ListView) findViewById(android.R.id.list);
// 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});
//adapter = new ArrayAdapter<Question>(this, R.layout.user_question_list, questions);
setListAdapter ( adapter );
ListView lv = getListView();
lv.setTextFilterEnabled(true);
后来我像这样填充列表:
HashMap<String, String> map = new HashMap<String, String>();
JSONObject o = obj.getJSONObject(i);
String question_id = o.getString("question_id");
String question = o.getString("question");
String questioner_id = o.getString("member_id");
String first_name = o.getString("first_name");
String last_name = o.getString("last_name");
Question q = new Question ( );
q.setQuestion(question);
q.setQuestionId(question_id);
q.setQuestionByMemberId( questioner_id );
q.setAuthorName(first_name + " " + last_name );
map.put("train", question);
//map.put("from", ">");
map.put("to", ">");
fillMaps.add(map);
questions.add( q );