I am trying to show elements in a list view using Fragments. I created my custom view as follow
graphical representation of list_row.xml
list_row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip" >
<!-- ListRow Left sied Thumbnail image -->
<LinearLayout
android:id="#+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="3dip" >
<ImageView
android:id="#+id/list_image"
android:layout_width="50dip"
android:layout_height="50dip"
android:contentDescription="#string/image_desc"/>
</LinearLayout>
<!-- Menu name -->
<TextView
android:id="#+id/menu_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/thumbnail"
android:layout_toRightOf="#+id/thumbnail"
android:text="#string/menu_name"
android:textColor="#040404"
android:textSize="15sp"
android:textStyle="bold"
android:typeface="sans" />
<!-- Description -->
<TextView
android:id="#+id/description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/thumbnail"
android:layout_below="#id/menu_name"
android:layout_marginTop="1dip"
android:layout_toRightOf="#+id/thumbnail"
android:text="#string/description"
android:textColor="#343434"
android:textSize="10sp"
tools:ignore="SmallSp" />
<!-- Price -->
<TextView
android:id="#+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#id/menu_name"
android:layout_marginRight="5dip"
android:gravity="right"
android:text="#string/price"
android:textColor="#10bcc9"
android:textSize="10sp"
android:textStyle="bold"
tools:ignore="SmallSp" />
</RelativeLayout>
In fragment.xml file, I simply put a list view inside a linear layout
fragment.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</LinearLayout>
I have an array of menu objects, that has the necessary fields to populate list_row.xml like menu name, description, price and image. I couldn't find a way to fill fragment.xml's listView with the list_row elements. Any help or idea would be appreciated.
PS: I think in fragment.xml instead of android:id="#+id/listView1" field, I have to write android:id="#id/list" since I'm using ListFragment
I solved my problem (as system32 suggests on comment) creating a CustomArrayAdapter class, and setting it as the adapter for my listView.
First I changed android:id="#+id/listView1" to android:id="#android:id/list" in fragment.xml.
CustomArrayAdapter.java
public class CustomArrayAdapter extends ArrayAdapter<Menu> {
Context context;
public CustomArrayAdapter(Context context, int textViewResourceId, List<Menu> objects) {
super(context, textViewResourceId, objects);
// TODO Auto-generated constructor stub
this.context = context;
}
/*private view holder class*/
private class ViewHolder {
ImageView imageView;
TextView txtMenuName;
TextView txtMenuDesc;
TextView txtPrice;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
Menu rowItem = getItem(position);
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_row, null);
holder = new ViewHolder();
holder.txtMenuName = (TextView) convertView.findViewById(R.id.menu_name);
holder.txtMenuDesc = (TextView) convertView.findViewById(R.id.description);
holder.txtPrice = (TextView) convertView.findViewById(R.id.price);
holder.imageView = (ImageView) convertView.findViewById(R.id.list_image);
convertView.setTag(holder);
} else
holder = (ViewHolder) convertView.getTag();
holder.txtMenuDesc.setText(rowItem.getDescription());
holder.txtMenuName.setText(rowItem.getName());
holder.txtPrice.setText(String.valueOf(rowItem.getPrice()) + " TL");
//holder.imageView.setImageResource(rowItem.getImageId());
return convertView;
}
}
Then I use it in my Fragment class
public static class Fragment extends ListFragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
public static final String ARG_SECTION_NUMBER = "section_number";
private ListView listView;
private ArrayList<Menu> menuItems;
private CustomArrayAdapter mAdapter;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment,
container, false);
listView = (ListView) rootView.findViewById(android.R.id.list);
return rootView;
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
int num = getArguments().getInt(ARG_SECTION_NUMBER);
// GlobalList is a class that holds global variables, arrays etc
// getMenuCategories returns global arraylist which is initialized in GlobalList class
menuItems = GlobalList.getMenuCategories().get(num).getMenu();
mAdapter = new CustomArrayAdapter(getActivity(), android.R.id.list, menuItems);
listView.setAdapter(mAdapter);
}
}
Related
I'm trying to put a list view inside a fragment. I made tries and here is what I got (My app is working, but the list view simply doesn't appear.):
The Fragment I want the list in:
public class Trechos extends Fragment {
ListView list;
#Override
//Método para inflar o layout
public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState){
//Variável view to tipo View infla o layout a ser usado
View view = inflater.inflate(R.layout.trechos, container, false);
Classe classe = new Classe(getActivity());
list = (ListView) view.findViewById(R.id.list);
list.setAdapter(classe);
//retorna a variável view
return view;
}
}
The xml for the fragment:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
<ListView
android:id="#id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="adasdasds">
</ListView>
</LinearLayout>
The custom adapter I created to insert the informations:
public class Classe extends ArrayAdapter<String> {
private final Activity context;
private String [] trechos = {"a", "b"};
private int [] posicao = {1,2};
public Classe(Activity context) {
super(context, R.layout.row_layout);
this.context = context;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rootView = inflater.inflate(R.layout.row_layout, null, true);
TextView txtPosicao = (TextView) rootView.findViewById(R.id.posicao);
TextView txtTrecho = (TextView) rootView.findViewById(R.id.trechos);
txtPosicao.setText(posicao[position]);
txtTrecho.setText(trechos[position]);
return rootView;
}
}
And the xml for the custom rows:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow>
<TextView
android:textSize="20sp"
android:textStyle="bold"
android:padding="5dp"
android:id="#+id/posicao"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView
android:textStyle="italic"
android:textSize="20sp"
android:padding="5dp"
android:id="#+id/trechos"
android:layout_width="match_parent"
android:layout_height="50dp" />
</TableRow>
</TableLayout>
I'm getting a warning like Unconditional layout inflation which is causing the layout to exit and app goes crashing.I need to inflate this layout without crashing.
the crashing is on the following code.
I have the code for the custom adapter set.
public class CustomAdapter extends BaseAdapter {
private List<Response.NodesEntity> mMovieitem;
private Context mContext;
private LayoutInflater inflater;
public CustomAdapter(Context mContext, List<Response.NodesEntity> mMovieitem) {
this.mContext = mContext;
this.mMovieitem = mMovieitem;
}
#Override
public int getCount() {
return mMovieitem.size();
}
#Override
public Object getItem(int position) {
return mMovieitem.get(position);
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.s, parent, false);
Response.NodesEntity item = (Response.NodesEntity) getItem(position);
ImageView thumbnail = (ImageView) rowView.findViewById(R.id.thumbnail);
TextView title = (TextView) rowView.findViewById(R.id.title);
TextView rating = (TextView) rowView.findViewById(R.id.video_url);
String imageUrl = item.getVideoTumbnail().getSrc();
Picasso.with(mContext).load(imageUrl).into(thumbnail);
title.setText(item.getTitle());
rating.setText(item.getHlsVideo());
return rowView;
}
}
The Xml is in this format . I'm inflating this layout and
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="#+id/video_list"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="info.androidhive.materialdesign.activity.FriendsFragment">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_margin="5dp">
<ImageView
android:id="#+id/thumbnail"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/background_material_light"
android:scaleType="centerCrop" />
<TextView
android:layout_marginBottom="10dp"
android:layout_gravity="bottom"
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/thumbnail"
android:layout_toEndOf="#+id/thumbnail"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:typeface="sans"
android:textSize="22sp"
android:textColor="#ffffff" />
<TextView
android:layout_marginTop="20dp"
android:id="#+id/video_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/title"
android:layout_toEndOf="#+id/thumbnail"
android:layout_toRightOf="#+id/thumbnail"
android:visibility="invisible"/>
</android.support.v7.widget.CardView>
</RelativeLayout>
use View holder method for inflating each rows
I want to know why it tells me: "Unfortunately your app has stopped"?
I followed all the steps in this video:
https://www.youtube.com/watch?v=0zQCv0Xb3pk&index=84&list=PLonJJ3BVjZW6hYgvtkaWvwAVvOFB7fkLa
my code in main Activity
public class MainActivity extends Activity {
ListView list;
String[] mimititles;
String[] description;
int[] images = {R.drawable.m1,R.drawable.m2,R.drawable.m3,R.drawable.m4,R.drawable.m4,
R.drawable.m5,R.drawable.m6,R.drawable.m7,R.drawable.m8,R.drawable.m9,R.drawable.m10};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Resources res= getResources();
mimititles= res.getStringArray(R.array.title);
description = res.getStringArray(R.array.description);
list=(ListView)findViewById(R.id.listView);
ibrahimadapter adapter = new ibrahimadapter(this,mimititles,images,description);
list.setAdapter(adapter);
}
}
class ibrahimadapter extends ArrayAdapter<String>
{
Context context;
int[] images;
String [] tiltearray;
String [] descrip;
ibrahimadapter(Context c,String[]titles,int[]imgs,String[] desc )
{
super(c,R.layout.single_row,R.id.textView1,titles);
this.context=c;
this.images=imgs;
this.tiltearray=titles;
this.descrip=desc;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View raw=inflate.inflate(R.layout.single_row,parent,false);
ImageView myimage= (ImageView) raw.findViewById(R.id.imageView1);
myimage.setImageResource(images[position]);
TextView mytitle = (TextView) raw.findViewById(R.id.textView1);
mytitle.setText(tiltearray[position]);
TextView mydescription = (TextView) raw.findViewById(R.id.textView2);
mydescription.setText(descrip[position]);
return raw;
}
}
my code in activity_main.xml layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android1="http://schemas.android.com/apk/res/android"
xmlns:android2="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ListView
android2:id="#+id/listView"
android2:layout_width="match_parent"
android2:layout_height="wrap_content"
>
</ListView>
</LinearLayout>
my code in single_row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="10dp"
android:src="#drawable/m1" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/imageView1"
android:layout_toRightOf="#+id/imageView1"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView1"
android:layout_alignLeft="#+id/textView1"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView1"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
In your adapter:
your constructor should be: public ibrahimadapter(....) {.....}
getView function change to:
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final Holder holder;
View raw = converView;
if(raw == null){
raw=inflate.inflate(R.layout.single_row,parent,false);
holder = new Holder();
holder.imgView = (ImageView) raw.findViewById(R.id.imageView1);
holder.myTitle = (TextView) raw.findViewById(R.id.textView1);
holder.myDes = (TextView) raw.findViewById(R.id.textView2);
raw.setTag(holder)
} else {
holder=(Holder)raw.getTag();
}
holder.imgView.setImageResource(images[position]);
holder.myTitle.setText(tiltearray[position]);
holder.myDes.setText(descrip[position]);
return raw;
}
public static class Holder {
ImageView imgView;
TextView myTitle;
TextView myDes;
}
Try this:
Change this
super(c,R.layout.single_row,R.id.textView1,titles)
To this
super(c,R.layout.single_row,titles)
Please check that the number of items for each String[] mimititles, String[] description and int[] images are all of the same length.
E.g if you want to show 5 item in the List, then you must 5 images, 5 mimititles and 5 description.
So check your string-array files
I want to have different background color of each item of listview. Following is my code for getView() method of custom adaptor.
public View getView(int position, View convertView, ViewGroup parent) {
convertView = mInflater.inflate(mViewResourceId, null);
View v = super.getView(position, convertView, parent);
RatingBar ratingBar = ((RatingBar)convertView.findViewById(R.id.my_choices_row_rating));
ratingBar.setRating(mRatings[position]);
TextView tv = (TextView)convertView.findViewById(R.id.my_choices_row_text);
tv.setText(mStrings[position]);
Log.v(TAG,"getView nalist=" + mNAList[position]);
Log.v(TAG,"getView gotlist=" + mGotList[position]);
if(mNAList[position].equalsIgnoreCase("N/A")){
TextView tv1 = (TextView)convertView.findViewById(R.id.my_choices_row_na_text);
tv1.setText(mNAList[position]);
}
if(mGotList[position].equalsIgnoreCase("Purchased")){
TextView tv2 = (TextView)convertView.findViewById(R.id.my_choices_row_got_text);
tv2.setText(mGotList[position]);
}
convertView.setBackgroundColor(mColors[position]);
return convertView;
}
}
Here is my xml file for the row of the list
<?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="horizontal">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id = "#+id/RHE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:padding="5dp"
android:layout_span = "3">
<TableRow android:layout_height="wrap_content">
<RatingBar
android:id="#+id/my_choices_row_rating"
android:progressDrawable="#drawable/hearts_rating_bar"
android:layout_width="fill_parent"
android:paddingTop="5dp"
android:layout_height="25sp"
android:numStars="5"
android:stepSize="1" />
<TextView
android:id="#+id/my_choices_row_text"
android:paddingLeft="2px"
android:paddingRight="2px"
android:paddingTop="2px"
android:textSize="18sp"
android:gravity="left|center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<CheckBox
android:id="#+id/my_choices_row_checkBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="right"
android:focusable="false"
android:focusableInTouchMode="false"
/>
</TableRow>
<TableRow android:layout_height="wrap_content">
<TextView
android:id="#+id/my_choices_row_na_text"
android:textSize="12sp"
android:gravity="left|center"
android:textColor="#8B0000"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/my_choices_row_got_text"
android:textSize="12sp"
android:textColor="#8B0000"
android:gravity="left"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
</LinearLayout>
I keep on getting following error
06-01 00:20:52.057: E/AndroidRuntime(711):FATAL EXCEPTION:main
06-01 00:20:52.057: E/AndroidRuntime(711):java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
06-01 00:20:52.057: E/AndroidRuntime(711):at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:386)
Your tutorial
Ask me if there are anything you dont understant
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//your colors list
ArrayList<Integer> colors = new ArrayList<Integer>();
for(int i = 0; i < 10; i++){
Random ran = new Random();
int color = ran.nextInt();
colors.add(color);
}
//get listview and set adapter for it
ListView lv = (ListView) findViewById(R.id.myListView);
lv.setAdapter(new MyColorAdapter(this, colors));
}
public class MyColorAdapter extends ArrayAdapter<Integer>{
ArrayList<Integer> colors;
Context context;
public MyColorAdapter(Context context, ArrayList<Integer> colors) {
super(context, R.layout.row, colors);
this.colors = colors;
this.context = context;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.row, parent, false);
rowView.setBackgroundColor(colors.get(position));
return rowView;
}
}
}
I have to apply pagination concept on ListView my list view contains data parsed from web service. below is code given that how I have displayed data in list view as below.
try {
ArrayList<HashMap<String, String>> arl (ArrayList<HashMap<String, String>>) getIntent().getSerializableExtra("arraylist");
System.out.println("...serialized data.."+arl);
lv1 = (ListView) findViewById(R.id.lstlodgingresult);
adapter = new SimpleAdapter(this, arl, R.layout.custom_row_view,
new String[] { "Srno", "Names", "URL", "Address1", "Address2", "Telephone", "Category", "PetH",
"PetInfo" }, new int[] { R.id.txtSrno,R.id.txtname, R.id.txturl, R.id.txtaddress1, R.id.txtaddress2, R.id.txtphone, R.id.txtcategory,
R.id.txtpetpolicyH, R.id.txtpetpolicyC }
);
lv1.setScrollbarFadingEnabled(false);
lv1.refreshDrawableState();
lv1.setAdapter(adapter);
} catch (Exception e) {
e.printStackTrace();
}
you just need to add a Footer View in the Listyou created. Then for the footer view (might be button/image/text) set a ClickListener for that and in Listener add the items into your list and again refresh the activity. I am adding a little tutorial that will help you in this.
I used the following Method for Pagination:
The List Class:
public class customListView extends Activity implements OnClickListener{
private static class EfficientAdapter extends BaseAdapter {
private LayoutInflater mInflater;
Context context;
public EfficientAdapter(Context context) {
this.context = context;
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return add_Names.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.listcontent, null);
holder = new ViewHolder();
holder.text = (TextView) convertView
.findViewById(R.id.txt1);
holder.text2 = (TextView) convertView
.findViewById(R.id.txt2);
holder.text3 = (TextView) convertView
.findViewById(R.id.txt3);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.text.setText(add_Names.get(position).toString());
holder.text2.setText(location.get(position).toString());
holder.text3.setText(details.get(position).toString());
return convertView;
}
static class ViewHolder {
TextView text;
TextView text2;
TextView text3;
}
}//end of efficient Adapter Class
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview);
adapter = new EfficientAdapter(this);
l1 = (ListView) findViewById(R.id.ListView01);
View footerView =
((LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.layout_footer, null, false);
l1.addFooterView(footerView);
l1.setAdapter(adapter);
mLayout = (LinearLayout) footerView.findViewById(R.id.footer_layout);
more = (Button) footerView.findViewById(R.id.moreButton);
more.setOnClickListener(this);
l1.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Toast.makeText(getBaseContext(), "You clciked "+add_Names.get(arg2).toString(), Toast.LENGTH_LONG).show();
}
});
}
#Override
public void onClick(View v) {
switch(v.getId())
{
case R.id.moreButton:
//Your code to add some more data into list and then call the following to refresh your lits
adapter.notifyDataSetChanged();
break;
}//end of switch
}//end of onClick
}//end of Custom List view class
layout_footerview.xml:(you can add whatever you link in the footer for the list. I used button you can use Text or image or whatever you want)
<?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:paddingTop="7dip"
android:paddingBottom="7dip"
android:orientation="horizontal"
android:gravity="center">
<LinearLayout
android:id="#+id/footer_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_gravity="center">
<Button
android:text="Get more.."
android:id="#+id/moreButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="14dip"
android:textStyle="bold">
</Button>
</LinearLayout>
</LinearLayout>
listview.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="#+id/ListView01" android:layout_height="wrap_content"
android:layout_width="fill_parent">
</ListView>
</RelativeLayout>
list-content.xml:(modify as u like to be your list row)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView android:id="#+id/image1" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="#drawable/icon"></ImageView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/txt1" android:layout_toRightOf="#+id/image1"
android:text="Test Description" android:textSize="15dip" android:textStyle="bold">
</TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/txt2" android:layout_below="#+id/txt1" android:layout_toRightOf="#+id/image1"
android:text="Address" android:textSize="10dip"></TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/txt3" android:layout_below="#+id/txt2" android:layout_toRightOf="#+id/image1"
android:text="Details" android:textSize="10dip" ></TextView>
</RelativeLayout>
I Hop this will definetly help you.!
Mark this as true and UpVote; if this helps you.
Thanks
sHaH..