Displaying list in Android fragment -


i got fragment should display list every time try display list previous activity displayed in background.

so question is, how display list on empty page? can put instead of getactivity() in arrayadapter.

my xml looks this:

<?xml version="1.0" encoding="utf-8"?> <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/fundraiser"     android:layout_width="match_parent"     android:layout_height="wrap_content" > </listview> 

and code looks this

import android.os.bundle; import android.support.v4.app.listfragment; import android.view.view; import android.widget.arrayadapter; import android.widget.listview; import android.widget.toast;  public class fundraiserfragment extends listfragment{  string[] values = new string[] { "item 1", "item 2", "item 3"};  @override public void onactivitycreated(bundle savedinstancestate){     super.onactivitycreated(savedinstancestate);     arrayadapter<string> adapter = new arrayadapter<string>    (getactivity(),android.r.layout.simple_list_item_1,values);     setlistadapter(adapter); } 

don't forget layouts transparent default, unless assign them background color.

assign background color linearlayout of fragment in xml file , parent activity should disappear.

android:background="@android:color/white" 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -