How can I put arrows in listview same line? - android

I make a project and ı stuck in there.
In my design papers like that
And I did't put the arrow as seem so I can do it just Text side.
Like that
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 :)

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

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>

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>

Related

setOnItemClickListener won't work - why?

I got a custom listview:
trainingsplan_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="270dp"
android:layout_height="match_parent"
android:id="#+id/planinfolinearlayout"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/plannametv"
android:textColor="#color/darkPrimary"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/trainingszieltv"
android:layout_below="#+id/plannametv"
android:textColor="#color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/phasendauerbereichtv"
android:layout_below="#+id/trainingszieltv"
android:textColor="#color/white"/>
</LinearLayout>
<ImageButton
android:layout_width="70dp"
android:layout_height="wrap_content"
android:id="#+id/imageButtonInfo"
android:src="#drawable/informationsmall"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:layout_toRightOf="#+id/planinfolinearlayout"
android:background="#color/darkSecondary"
android:layout_marginTop="5dp"
android:focusable="false"
/>
</RelativeLayout>
The fragment:
final ListView planView = (ListView) getActivity().findViewById(R.id.listViewtrainingsplan);
planView.setItemsCanFocus(false);
PlanAdapter adapter = new PlanAdapter(getActivity(),R.layout.trainingsplan_item, arrayOfPlans);
planView.setAdapter(adapter);planView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
changeFocus(planView, position);
}
});
However, it does not call the method changeFocus when I try to debug.
I tried several solutions shown here on this website but none has worked for me, any ideas? Thanks in advance!
remove
planView.setItemsCanFocus(false);

ListView setOnItemClickListener Does Not Trigger

click listener not working when I click an item.
in this program first two arraylist updated using update(). then this list view are sent to other class to make list view. but clicking each item doesn't toast anything.
public class BlockActivity extends Activity {
ListView lv;
ArrayList<String> contactnumber= new ArrayList<String>();
ArrayList<String> contactname= new ArrayList<String>();
public static SQLiteDatabase database;
SQLiteDatabase myDB= null;
CustomAdapter adapter;
ArrayList<String> contactnum= new ArrayList<String>();
ArrayList<String> contactnam= new ArrayList<String>();
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button pickContact = (Button) findViewById(R.id.button1);
update();
lv=(ListView) findViewById(R.id.listView1);
adapter = new CustomAdapter(this, contactnam, contactnum);
lv.setAdapter(adapter);
lv.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id)
{
/*new AlertDialog.Builder(view.getContext())
.setMessage("Something here")
.setNegativeButton("Close", null).show();*/
Toast.makeText(BlockActivity.this,
"Item in position " + position + " clicked", Toast.LENGTH_LONG).show();
}
});
pickContact.setOnClickListener(new OnClickListener() {
.
.
.
main.xml:
<?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="fill_parent"
android:orientation="vertical" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="add" />
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
detail.xml:
<?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="vertical" android:focusableInTouchMode="false" android:focusable="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dip"
android:layout_weight="1" android:focusable="false" android:focusableInTouchMode="false">
<Button android:id="#+id/button2" android:layout_width="0dp" android:layout_height="wrap_content" android:text="Button"/>
<TextView
android:id="#+id/one"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="name"
android:textSize="20dip" android:layout_gravity="center" android:focusable="false" android:focusableInTouchMode="false"/>
<TextView
android:id="#+id/two"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="name"
android:textSize="20dip" android:layout_gravity="center" android:focusable="false" android:focusableInTouchMode="false"/>
</LinearLayout>
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="2dip" android:background="#ff7f7f"/>
Thats because of your Button, add android:descendantFocusability="blocksDescendants" in your list item root layout
detail.xml:
<?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="vertical"
android:descendantFocusability="blocksDescendants" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dip"
android:layout_weight="1" android:focusable="false" android:focusableInTouchMode="false">
<Button android:id="#+id/button2" android:layout_width="0dp" android:layout_height="wrap_content" android:text="Button"/>
<TextView
android:id="#+id/one"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="name"
android:textSize="20dip" android:layout_gravity="center"/>
<TextView
android:id="#+id/two"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="name"
android:textSize="20dip" android:layout_gravity="center"/>
</LinearLayout>
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="2dip" android:background="#ff7f7f"/>
If you have implemented onClik Listener in CustomAdapter class for Button in detail.xml then please remove it.
Because simultaneously you can not have click on listview's item click and customAdaptor's view click.
For TextViews and Button in your detail.xml add this piece of code
android:focusableInTouchMode="false"
android:clickable="false"
android:focusable="false"
There could be multiple views in listviews which can be clickable.
Best solution is :
1)Use android:descendantFocusability="blocksDescendants" in top-level container layout of list item.
2) Now whichever views in the listview needs to clickable, Use below attribute:
android:focusable="false"
android:focusableInTouchMode="false"
3)Set click listeners to the views and callback using interface to fragment or activity on click.

How to add 2 EditText entries into 1 rowitem of ListView?

Like it is said in the title I want to add 2 entries of two different EditText into 1 listrowitem of my ListView.
Now I just can add one entry.
onCreateView of my fragment
final ListView listView = (ListView) rootView.findViewById(R.id.listViewswipeview);
final EditText editText = (EditText) rootView.findViewById(R.id.editTextswipeView);
final EditText editText2 = (EditText) rootView.findViewById(R.id.editText2);
Button btnswipeview = (Button) rootView.findViewById(R.id.imagebuttonswipeview);
listItems = new ArrayList<String>();
listItems.add("First Item - added on Activity Create");
adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, listItems);
listView.setAdapter(adapter);
btnswipeview.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View View) {
Toast toast = Toast.makeText(getActivity(),
"You clicked the button",
Toast.LENGTH_SHORT);
toast.show();
listItems.add(editText.getText().toString());
adapter.notifyDataSetChanged();
}
});
My fragment xml swipeview.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Titel"
android:textSize="15pt"
android:id="#+id/swipeviewtitle"
android:layout_gravity="center_horizontal" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/swipeViewimage"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_launcher"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#CFD8DC">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/editTextswipeView"
android:layout_weight="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imagebuttonswipeview"
android:src="#drawable/ic_menu_add"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/editText2"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CFD8DC">
<ListView
android:layout_margin="5dp"
android:id="#+id/listViewswipeview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
tools:listitem="#layout/swipeviewrowitem"
android:clickable="true"
android:drawSelectorOnTop="true"
android:focusable="true"
android:choiceMode="singleChoice"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinnerswipeview"
android:entries="#array/day"
android:layout_gravity="center_horizontal"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
my rowitem xml swipeviewrowitem.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerVertical="true"
android:descendantFocusability="blocksDescendants"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/new.workout"
android:textColor="#000000"
android:id="#+id/mainText"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/textView2"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
So if I make a entry in each of the two EditText objects the first one should be added to android:id="#+id/mainText" and the second one to android:id="#+id/textView2" of the listrowitem.
How is it possible to do it?
Rather than using the stock ArrayAdapter with a built-in row layout:
adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, listItems);
you'll probably want to create your own Adapter that extends ArrayAdapter, and pass it your custom row layout R.layout.swipeviewrowitem. You can add logic inside the custom Adapter to handle inputs to the EditTexts.

Listview click listener not responding

I have a list view and want to perform clickable event on it. I did it before. but now its not working. I have added my XML as well. I just need to move from one actvity to other on click in list view.
CustomFinalSubmit_ItemDetail item = new CustomFinalSubmit_ItemDetail(Final_Submit.this , R.layout.customview_finalsubmit_itemdetails, itemInfo);
itemList.setAdapter(item);
itemList.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
FinalSubmitItem pos = itemInfo.get(position);
String itemType = pos.getItemType();
String itemCountry = pos.getItemCountry();
String itemSerial = pos.getItemNo();
pos.setChecked(true);
Intent inn = new Intent(getApplicationContext(), FinalSubmitDetails.class);
inn.putExtra("itemType", itemType);
inn.putExtra("itemCountry", itemCountry);
inn.putExtra("itemSerial", itemSerial);
startActivity(inn);
}
});
Here is my main Xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/green">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill"
android:layout_marginTop="10dip"
android:orientation="vertical"
android:background="#0B3B0B">
<ListView
android:id="#+id/CustomerDetailList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/yellow"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:id="#+id/Itemtype"
android:paddingTop="5dp"
android:background="#color/green"
android:textColor="#color/yellow"
android:layout_marginLeft="5dip"
android:text="Item Type"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:paddingTop="5dp"
android:id="#+id/txtcountry"
android:background="#color/green"
android:textColor="#color/yellow"
android:text="Country"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:paddingTop="5dp"
android:id="#+id/txtItemNumber"
android:background="#color/green"
android:textColor="#color/yellow"
android:text="Item No."/>
<CheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:id="#+id/itemChck"
android:button="#drawable/custom_checkbox"
android:paddingTop="5dp"
android:padding="5dp"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_margin="5dp"
android:layout_height="1dp"
android:background="#color/white"/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/itemList"
android:background="#088A08"
android:divider="#color/white"
android:dividerHeight="1dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I did it this way:
convertView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
your code
}});
Just add this much code to my customview
Recently I had the same problem after adding a ToggleButton to my list items. The solution for me was to add android:descendantFocusability="blocksDescendants" to the layout of the item.
Here is the whole 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="wrap_content"
android:layout_margin="5dp"
android:padding="5dp"
android:paddingLeft="15dp"
android:descendantFocusability="blocksDescendants" >
<TextView
android:id="#+id/watch_roadName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Addresse"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<ToggleButton
android:id="#+id/watch_button_arrived"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/watch_roadName"
android:layout_alignParentRight="true"
android:textOn="#string/arrived"
android:textOff="#string/arrived"
android:text="#string/arrived" />
</RelativeLayout>
Similar answers to the same issue can be found here:
How to fire onListItemClick in Listactivity with buttons in list?
and here
Android custom ListView with ImageButton is not getting focus
in the widgets(Textview or button whatever it is) of your inflator layout just add:
android:focusable="false"
android:focusableInTouchMode="false"
and in parent layout of your inflator add:
android:descendantFocusability="blocksDescendants"

Set gravity in list item layout

I have a problem with setting gravity of a list item layout. I have a list layout which has 2 textviews. The first one has right gravity and second one has left gravity. When I load list view I always get right gravity.
Here is my code:
<?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="vertical" >
<TextView
android:id="#+id/poem_verse_list_item_01"
style="#style/TextAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right" />
<TextView
android:id="#+id/poem_verse_list_item_02"
style="#style/TextAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:gravity="left" />
</LinearLayout>
And here is my Cursor and its ViewBinder:
public class CustomViewBinder implements ViewBinder {
#Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
int getIndex = cursor.getColumnIndex(ClubCP.COLUMN_POSITION);
int position = cursor.getInt(getIndex);
// Log.i("ViewBinder position",position);
TextView right =(TextView)view;
int viewId = view.getId();
switch(position){
case 0 :
// Right = 0,
if(viewId==R.id.poem_verse_list_item_02){
view.setVisibility(view.GONE);
}
else if(viewId==R.id.poem_verse_list_item_01){
view.setVisibility(view.VISIBLE);
}
//left.setVisibility(left.GONE);
//right.setGravity(Gravity.RIGHT);
// text.setVisibility(text.GONE);
// return true;
case 1:
// Left = 1,
if(viewId==R.id.poem_verse_list_item_02){
view.setVisibility(view.GONE);
}
else if(viewId==R.id.poem_verse_list_item_01){
view.setVisibility(view.VISIBLE);
}
//left.setVisibility(left.GONE);
//right.setGravity(Gravity.LEFT);
// return true;
case 2:
case 3:
case 4:
case -1:
}
return false;
}
}
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.poem_verse_list_item, c,
columns, new int[] {R.id.poem_verse_list_item_01,R.id.poem_verse_list_item_02}, 0);
I tested a lot but each time I get only right or left gravity for both of them... I hope some one can help me. Thanks for your time.
This is my activity including ListView layout:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/FrameLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff64512f"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context=".Read_peom" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="#drawable/list_top_repeat" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:scaleType="fitXY"
android:src="#drawable/list_bottom_repeat" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="#drawable/list_left_repeat" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:scaleType="fitXY"
android:src="#drawable/list_right_repeat" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="#drawable/list_top_left_no_repeat" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="#drawable/list_top_right_no_repeat" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:src="#drawable/list_bottom_left_no_repeat" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:src="#drawable/list_bottom_right_no_repeat" />
<TextView
android:id="#+id/txt_poem_container_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ListView
android:id="#+id/list_poem_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal|center"
android:layout_margin="#dimen/list_top_margin"
android:choiceMode="none"
android:clickable="false"
android:longClickable="false"
android:padding="5dp" >
</ListView>
Remove android:layout_gravity from both the TextViews since android:layout_width="match_parent"
OR
make android:layout_width="wrap_content" and remove android:gravity from both the TextViews.
ELSE
You may also try a RelativeLayout with TextViews having android:layout_width="wrap_content" and android:layout_alignParentLeft or android:layout_alignParentRight set to true accordingly.
Edit:
To debug the issue do the following. Create a ArrayAdapter with static data and set it as the list adapter.
String[] arr = {"a","b","c"};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.poem_verse_list_item, R.id.poem_verse_list_item_01, arr);
setListAdapter(adapter);
}
Then set some value using android:text to the TextViews like this.
<TextView
android:id="#+id/poem_verse_list_item_01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:text="poem_verse_list_item_01" />
<TextView
android:id="#+id/poem_verse_list_item_02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:gravity="left"
android:text="poem_verse_list_item_02"/>
So if the problem persists then the issue is not with the view binder. I would suggest you to redesign your main layout file containing the ListView.
Try change android:orientation="vertical"
to
android:orientation="horizontal"
Hope this helped you

Categories

Resources