Rıdvan
Rıdvan

Reputation: 740

How can I put arrows in listview same line?

I make a project and ı stuck in there. In my design papers like that enter image description here

And I did't put the arrow as seem so I can do it just Text side.

Like that

enter image description here

How can I put the Arrows ?

My codes are

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;
        }
    }
});

**My 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> 

This is my Listview Normaly

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

        </ListView>

If you can help my I'm be so greteful :)

Upvotes: 2

Views: 3968

Answers (3)

Hamza Awwad
Hamza Awwad

Reputation: 163

change the row to

<?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>

and then change the adapter declaration to

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

Upvotes: 5

Chris Wilson
Chris Wilson

Reputation: 248

Make the base layout of your simplerow a RelativeLayout and set the values kind of like this. You can make the arrow a drawable ImageView if you'd prefer. May have to change settings but this should work.

<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>

Upvotes: 1

Francesc
Francesc

Reputation: 29320

Change your row layout like this:

<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>

Upvotes: 0

Related Questions