i want to put my textview under the imageview in listview when im trying to use the relative it give some error so i use the linearlayout but i can't put the textview under the imageview can you plwese help me thankyou advance?
xml in listview:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://ift.tt/nIICcg"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bacground"
android:orientation="horizontal" >
<ListView
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1" />
</LinearLayout>
xml in listview_layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/flag"
android:layout_width="400dp"
android:layout_height="300dp"
android:contentDescription="@string/hello"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center" >
<Textview
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/white"
android:layout_marginTop="90dp"
android:layout_marginRight="1dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:textSize="20dp" />
</LinearLayout>
my code:
OnItemClickListener itemClickListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View container,
int position, long id) {
Intent b_intent = new Intent(getApplicationContext(),
PicSelectActivity.class);
startActivity(b_intent);
// Getting the Container Layout of the ListView
LinearLayout linearLayoutParent = (LinearLayout) container;
// Getting the inner Linear Layout
LinearLayout linearLayoutChild = (LinearLayout) linearLayoutParent
.getChildAt(1);
// Getting the Country TextView
TextView tvCountry = (TextView) linearLayoutChild.getChildAt(0);
Editor editor = sharedpreferences.edit();
editor.putString("getFrame", tvCountry.getText().toString());
editor.commit();
}
};
// Setting the item click listener for the listview
listView.setOnItemClickListener(itemClickListener);
No comments:
Post a Comment