listview - 使用数据android加载listview时,将voiceover与listview的结尾对齐

  显示原文与译文双语对照的内容

我正在设计定制布局的自定义 listview 。 我需要在listview和 @+id/progressBar1 上面添加一个,当listview完成从web服务加载数据的时候。

在这种情况下,listview.addFooterView(View v) 无法使用,因为我使用来自第三方库的自定义PullToRefreshListview来刷新 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_上面="@+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);
}

时间: 原作者:

尝试更改这里代码:


 View footer_image=inflater.inflate(R.layout.listview_image_footer, container,false);

用这个:


 View footer_image=inflater.inflate(R.layout.listview_image_footer,null);

注意:这里的容器是指 fragment xml,尝试将自定义页脚添加到容器中,以便将页脚作为 null,而不是容器为 null

原作者:
...