2016-03-14 67 views
1

我做了一個項目,我卡在那裏。 在我這樣的設計論文中enter image description here我怎樣才能把箭頭放在listview同一行?

而且我沒有把箭頭看起來像是這樣,所以我可以只做文本一面。

就像那個

enter image description here

我怎樣才能把箭?

我的代碼是

String[] maddeler = new String[] { "YÖNETİM KURULU BAŞKANI FİKRİ ÖZTÜRK'ÜN MESAJI", "GENEL MÜDÜR CÜNEYT AĞCA İLE RÖPORTAJ", "21. YILINDA OPET", 
     "MİSYONUMUZ VİZYONUMUZ DEĞERLERİMİZ"}; 
ArrayList<String> maddelerListe = new ArrayList<String>(); 
maddelerListe.addAll(Arrays.asList(maddeler)); 



listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, maddelerListe); 





mainListView.setAdapter(listAdapter); 

mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
    @Override 
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 


     switch(position) 
     { 
      case 0: 

       Intent baskanlar =new Intent(getBaseContext(),BaskanlarSplash.class); 
       startActivity(baskanlar); 

       break; 
      case 1: 

       Intent baskanlar2=new Intent(getBaseContext(),BaskanlarSplash2.class); 
       startActivity(baskanlar2); 

       break; 

      case 2: 
       Toast.makeText(getBaseContext(),"içerik bekleniyor",Toast.LENGTH_LONG).show(); 
       break; 
      case 3: 
       Toast.makeText(getBaseContext(),"içerik bekleniyor",Toast.LENGTH_LONG).show(); 
       break; 
     } 
    } 
}); 

**我simplerow.xml **

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rowTextView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="10dp" 
    android:textSize="16sp" 
    android:textColor="@color/homeBac" 
    > 
</TextView> 

這是我的列表視圖Normaly

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

     </ListView> 

如果你能幫助我的我真是太可惜了:)

回答

2

改變該行

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal"> 

    <TextView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/rowTextView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="10dp" 
     android:textColor="@color/colorAccent" 
     android:textSize="16sp" 
     android:layout_weight="1"></TextView> 


    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@android:drawable/ic_dialog_info" /> 
</LinearLayout> 

,然後更改適配器聲明

ArrayAdapter<String> listAdapter = 
new ArrayAdapter<String>(this, R.layout.simplerow,R.id.rowTextView, maddelerListe); 
0

更改排佈局是這樣的:

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal"> 

    <TextView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"/> 
    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_your_arrow"/> 
</LinearLayout> 
0

讓你simplerow一個的RelativeLayout的基地佈局和設置的值有點像這樣。如果你願意,你可以使箭頭成爲可繪製的ImageView。可能需要更改設置,但這應該起作用。

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TextView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/rowTextView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentStart="true" 
     android:padding="10dp" 
     android:textSize="16sp" 
     android:textColor="@color/homeBac" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentEnd="true" 
     android:padding="10dp" 
     android:textSize="16sp" 
     android:textColor="@color/homeBac" 
     android:text=">" /> 

</RelativeLayout>