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