I am designing an custom listview with custom layout . In that I need to add an Imageview to the very end of listview and above @+id/progressBar1
,when the listview is finished with loading the data from web service.
In this case listview.addFooterView(View v)
cannot be use , because I used a custom PullToRefreshListview from third-party library Pull to refresh listview
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/lay_top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<com.rb.library.ScrollingTextView
android:id="@+id/txtTicker"
style="@style/style_bottom_marque"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:visibility="gone"
app:typeface="roboto_condensed" />
<include
android:id="@+id/pan_breaking_new"
layout="@layout/breaking_news" />
</LinearLayout>
<View
android:id="@+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@+id/lay_top"
android:background="#ccc"
android:paddingTop="2dip" />
<com.devspark.robototextview.widget.RobotoTextView
android:id="@+id/txt_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/view1"
android:layout_gravity="fill_horizontal"
android:drawableRight="@drawable/ic_title_arrow"
android:gravity="left|center_vertical"
android:inputType="textCapWords"
android:padding="5dip"
android:text="@string/TITLE_TOP_NEWS"
app:typeface="roboto_black" android:visibility="gone"/>
<View
android:id="@+id/view2"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@+id/txt_title"
android:background="#ccc" />
<com.handmark.pulltorefresh.library.PullToRefreshListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/view2"
android:layout_margin="2dip"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:divider="#cccccc"
android:dividerHeight="1dp" />
<com.devspark.robototextview.widget.RobotoTextView
android:id="@+id/main_error"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="fill_horizontal"
android:gravity="center_horizontal"
android:padding="20dip"
android:text="@string/INTERNET_ERR"
android:visibility="gone"
app:typeface="roboto_black" />
<ImageView
android:id="@+id/img_error"
android:layout_below="@+id/main_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:contentDescription="Error"
android:layout_centerInParent="true"
android:visibility="gone"
android:src="@drawable/ic_error" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/progressBar1"
android:layout_below="@+id/listView">
<ImageView
android:id="@+id/list_footer_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/app_logo"
android:visibility="visible"/>
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="25dip"
android:layout_height="25dip"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
HomFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.listview_layout, container,false);
View footer_image=inflater.inflate(R.layout.listview_image_footer, container,false);
/* get theme webservice*/
StrictMode.ThreadPolicy policy1 = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy1);
userFunction=new UserFunctions();
//Breaking News Section
slide = AnimationUtils.loadAnimation(getActivity(), R.anim.slidedown);
fadeOut = AnimationUtils.loadAnimation(getActivity(), R.anim.fadeout);
pan_breaking_new = (LinearLayout)rootView.findViewById(R.id.pan_breaking_new);
//pan_breaking_new.setOnClickListener(this);
pan_breaking_new.setVisibility(8);
btn_close= (ImageView) rootView.findViewById(R.id.btn_close);
btn_close.setOnClickListener(this);
img_share= (ImageView) rootView.findViewById(R.id.img_share);
img_share.setOnClickListener(this);
//END Breaking News Section
//Ticker
marque = (ScrollingTextView)rootView.findViewById(R.id.txtTicker);
marque.setVisibility(8);
//END ticker
main_error = (TextView) rootView.findViewById(R.id.main_error);
main_error.setText("Loading...");
img_error = (ImageView) rootView.findViewById(R.id.img_error);
img_error.setOnClickListener(this);
progressBar1 = (ProgressBar) rootView.findViewById(R.id.progressBar1);
progressBar1.setVisibility(8);
//karthik
refreshable_listView = (PullToRefreshListView) rootView.findViewById(R.id.listView);
listView=refreshable_listView.getRefreshableView();
listView.addFooterView(footer_image);
}
Try to change this code :
View footer_image=inflater.inflate(R.layout.listview_image_footer, container,false);
With this :
View footer_image=inflater.inflate(R.layout.listview_image_footer,null);
Note : here container is refer fragment xml,try to add custom footer to ListView which contain in container so give root value for footer as null instead of container
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.