2014-09-08 3 views
1

Я пытаюсь показать несколько данных на экране просмотра списка Android, но моя проблема заключается в том, что данные продолжают разрывать строки столбцов, а не появляться в соответствующих столбцах. Вот мой XML: Я пытаюсь показать несколько данных в виде списка андроидов

<ListView 
    android:id="@+id/listView" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:layout_centerInParent="true" 
    android:choiceMode="singleChoice" 
    android:textAlignment="center"/> 

</RelativeLayout> 

Вот как определяются строки:

<?xml version="1.0" encoding="utf-8"?> 
<!-- row.xml --> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:paddingTop="4dip" 
    android:paddingBottom="6dip" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:layout_gravity="center"> 



    <TextView android:id="@+id/FROM_CELL" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="right"/> 

    <TextView android:id="@+id/FROMTIME_CELL" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="right"/> 

    <TextView android:id="@+id/TOTIME_CELL" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="right"/> 

    <TextView android:id="@+id/TITLE_CELL" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="right" 
     android:layout_weight="1"/> 

</LinearLayout> 

Различные столбцы на экране никогда не приходит на той же колонке, но сдвинуты вправо на точная длина данных в предыдущем столбце. Пожалуйста, дайте мне знать, как позаботиться об этом. Заранее спасибо :)

+0

Кажется, я не могу добавить скриншот, пожалуйста, сообщите, есть ли возможность. – cbandroid

+0

Вы должны загрузить на tinypic или где-то :) –

+0

@cbandroid Я загрузил ответ, попробую, чтобы он вам помог ... :) – Umair

ответ

0

попробовать это будет работать нормально ...

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 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:gravity="center_vertical" 
android:orientation="horizontal" > 

<TextView 
android:id="@+id/txt_userName" 
android:layout_width="0dp" 
android:layout_height="19dp" 
android:layout_weight="2" 
android:gravity="center" /> 

<TextView 
android:id="@+id/txt_fName" 
android:layout_width="0dp" 
android:layout_height="19dp" 
android:layout_weight="2" /> 

<TextView 
android:id="@+id/txt_lName" 
android:layout_width="0dp" 
android:layout_height="19dp" 
android:layout_weight="3.51" 
android:gravity="left" /> 

</LinearLayout> 

и во втором 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:gravity="center_horizontal" > 

<View 
android:id="@+id/a" 
android:layout_width="match_parent" 
android:layout_height="0dp" 
android:paddingBottom="10dp" /> 

<ListView 
android:id="@+id/List" 
android:layout_width="match_parent" 
android:layout_height="match_parent" /> 

</RelativeLayout> 

Hope это hepls ....

+0

спасибо, этот метод работает для меня :-) – cbandroid

+0

@cbandroid вы можете принять его как ответьте и поддержите его, пожалуйста, чтобы другие могли также получить помощь и меня тоже ... :) – Umair

+0

Я принял это, но я не могу голосовать, так как у меня недостаточно репутации, я думаю, это потому, что я здесь новый ... извините за это :) – cbandroid

Смежные вопросы