1

我有这个布局:

<?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="horizontal"
     android:weightSum="1.0">

     <TextView android:id="@+id/TRAIN_CELL"
         android:layout_weight=".8"
         android:layout_height="wrap_content"
         android:layout_width="0dip"        
         android:textSize="16sp"/>

     <TextView android:id="@+id/TO_CELL"
         android:textSize="20sp"
         android:textStyle="bold" 
         android:gravity="center"
         android:textColor="@color/light_best_blue"
         android:layout_height="wrap_content"
         android:layout_width="0dip"  
         android:layout_weight=".2"/>

</LinearLayout>

这是在父屏幕中引用它的片段

<ListView
android:id="@android:id/list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:text="@+id/label"
    android:textSize="17sp"> 
</ListView> 

在此处输入图像描述

我试图在左侧有一些文本,在右侧有一个 > 字符,以便用户知道选择它。

这是我填充列表的方式:

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.my_problems,
            new String[] {"train", "to"}, 
            new int[] {R.id.TRAIN_CELL,  R.id.TO_CELL});        

                    for ( int i = 0; i < obj.length(); i++ )
                    {
                        HashMap<String, String> map = new HashMap<String, String>();
                        JSONObject o = obj.getJSONObject(i);                                

                        problem_title = o.getString("problem_title");
                        problem_id = o.getString("problem_id");
                        String has_new_comments = o.getString("has_new_comments");
                        String is_private = o.getString("is_private");

                        Problem p = new Problem ( );
                        p.setProblemId(problem_id);                         
                        p.setProblemName(problem_title);
                        p.setIsPrivate(is_private);
                        p.setHasNewComments(has_new_comments);

                        map.put("train", p.toString() );
                        map.put("to", ">");

                        fillMaps.add(map);
                        problems.add( p );                                                          
                    }

                    adapter.notifyDataSetChanged();                     

但是屏幕看起来很乱,左边的列出现在右边的列旁边,没有空格,“>”字符没有排列在同一列上,而是随机间隔,具体取决于左列结束的位置。

关于可能出了什么问题的任何想法?

谢谢!

4

0 回答 0