set imagebutton after listview and before footer tabbar - android

Hi,
I want to place two imagebuttons between listview and footer tabbar. If listview contains 10items then the buttons appear at last of the listview after displaying 10items in listview.
Please help.
thanks in advance.

I think ListView.addFooterView() is what you're looking for.
http://developer.android.com/reference/android/widget/ListView.html#addFooterView(android.view.View)

use this
View view mInflater.inflate(R.layout.list_load_more_row, null);
Button footer = (Button) view.findViewById(R.id.loadMore);
getListView().addFooterView(footer);
setListAdapter(ListViewHelper.getAdapterForContentList(mContent, this));
u can add header also in ur listview

Add FooterView in list view:
LayoutInflater inflater = activity.getLayoutInflater();
LinearLayout listFooterView = (LinearLayout)inflater.inflate(
R.layout.footer_layout, null);
list.addFooterView(listFooterView);

Related

Footerview not displaying always when scrolling the listview

I have a listview with an adapter. I want to add a footer and that this footer will be displayed when scrolling the listview. Right now with this code the footerview is displayed when the listview is finished. In the onCreate method of the list i have:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listado_imagenes_subidas_main);
// load list application
listImagenes = (ListView)findViewById(R.id.lvImages);
LayoutInflater inflater = getLayoutInflater();
ViewGroup footer = (ViewGroup) inflater.inflate(R.layout.footer3buttons, listImagenes,
false);
listImagenes.addFooterView(footer, null, false);
// create new adapter
ImagenesAdapter adapter = new ImagenesAdapter(this, ListadoImagenes());
// set adapter to list view
listImagenes.setAdapter(adapter);
}
Could you please help me with this issue?
Thank you in advanced.
If i understood correctly what you wan't is a "sticky" footer the addFooterView method add a footer after the last view item, for a sticky footer you have to roll your own, or use an external library for it.
try with this one
View footerView = ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
list.addFooterView(footerView);

Add a layout inside the list view

I wanted to display a web view in between in the list view and bottom of the list view.
I was able to add footer to the list view to display the web view in the bottom, but I don't know how to display in the middle
Code where I have added the footer:
ListView list = (ListView)view.findViewById(android.R.id.list);
WebView web;
LayoutInflater inflaterOf = getActivity().getLayoutInflater();
LinearLayout listFooterView =
(LinearLayout)inflaterOf.inflate(R.layout.list_footer, null);
web = (WebView)listFooterView.findViewById(R.id.webview_footer);
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("file:///android_asset/news_footer.html");
list.addFooterView(listFooterView);
Please let me know how to insert the layout with web view in-between the list view
You should create a custom object and in your ArrayAdapter of listview, change the layout to inflate when getCount is equal to list.size()/2.
That's the way I'll handle this.

Dynamically add divider to last item in list view

i am progrmatically adding list view to a linear layout like this:
ArrayList<Answer> ans = (ArrayList<Answer>) ques.getAnswers();
adapter = new AnswerAdapter(Test.this, ans);
ansList = new ListView(Test.this); // my list view adding dynamically
ansList.setAdapter(adapter);
ansList.setVerticalScrollBarEnabled(false);
ansList.setOnItemClickListener(cellClickListener);
ansLayout.addView(ansList);
Now the problem is it has the default divider after each item except the last item, i want the divider to be visible after the last item also.
I have looked into many questions in SO where they are adding views in the layout but i need to add programatically.
You can add footer view in listview... so make a layout of footerview... and bind as below
View footerView = ((LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.track_footer_view, null, false);
listview.addFooterView(footerView);
so you can have footerview at end of last item..
- Add that separator as the footer to your ListView.
Eg:
View mfooter = View.inflate(MyClass.this, R.layout.imagelayout, null);
lv.addFooterView(mfooter, null, false);

How can I add an ImageView as a ListView Header?

Can anyone help me to find out how to add an ImageView as a header to a ListView?
My code is here:
LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View snapshot = inflater.inflate(R.layout.map_snapshot, null);
ListView channelsList = (ListView) findViewById(R.id.channelsList);
channelsList.addHeaderView(snapshot);
By now it shows nothing.
Try inflating your header view passing the parent (ListView) as parameter:
ListView channelsList = (ListView) findViewById(R.id.channelsList);
View snapshot = inflater.inflate(R.layout.map_snapshot, channelList, false);
Then, just add it to the ListView:
channelsList.addHeaderView(snapshot);
Try:
ListView channelsList = (ListView) findViewById(R.id.channelsList);
LayoutInflater inflater = getLayoutInflater();
ViewGroup header = (ViewGroup)inflater.inflate(R.layout.map_snapshot, channelsList , false);
channelsList .addHeaderView(header, null, false);
In layout map_snapshot,you must be having parent layout as here i have taken Linear Layout likewise take that.
ListView channelsList = (ListView) findViewById(R.id.channelsList);
LinearLayout headerView = (LinearLayout) getLayoutInflater().inflate(R.layout.map_snapshot, null);
listView.addHeaderView(headerView);
if you want to add views in layout:
TextView mUsername=(TextView) headerView.findViewById(R.id.user_name);
You can use CommonsWare MergeAdapter or SectionedListAdapter. With this library you can use any View as Header in your Listview. See this SO question and accepted answer for more information.

Add a footer to a ListView in code

I am writing an app with a ListActivity with a footer whose contents are pretty dynamic based on certain situations. I wanted to use setFooterView like this:
Button addButton = new Button(this);
addButton.setText("Add");
addButton.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 35));
lv.addFooterView(addButton, null, true);
But it causes a Runtime exception. While using a layoutInflater may work with an XML layout (I use that for the header), how do I add a footer with programmatically constructed views?
View footerview;
footerview = getLayoutInflater().inflate(R.layout.listfooter, null);
Listview = (ListView)findViewById(R.id.listview);
Listview.setAdapter(adp);
......
....
Listview.addFooterView(footerview);
I think this might be useful .

Categories

Resources