Android ListView文本不使用视图切换程序显示
因此,我有一个片段,当进度条加载完毕后,应该会出现一个项目列表视图,然而,当LogCat向我显示这些项目确实是被收集的时候,屏幕上没有显示任何内容。为什么会这样?以下是我的代码和xml: 爪哇:Android ListView文本不使用视图切换程序显示,android,listview,Android,Listview,因此,我有一个片段,当进度条加载完毕后,应该会出现一个项目列表视图,然而,当LogCat向我显示这些项目确实是被收集的时候,屏幕上没有显示任何内容。为什么会这样?以下是我的代码和xml: 爪哇: 私有类showView扩展异步任务{ 骑乘[]次骑乘; ArrayList=新的ArrayList(); List ri=new ArrayList(); 字符串[]rideInfo; 弦长; 字符串设备ID; 字符串startZip; 长起点; 受保护的void onPreExecute(){ dev
私有类showView扩展异步任务{
骑乘[]次骑乘;
ArrayList=新的ArrayList();
List ri=new ArrayList();
字符串[]rideInfo;
弦长;
字符串设备ID;
字符串startZip;
长起点;
受保护的void onPreExecute(){
deviceId=device.getDeviceId();
sessionToken=SessionManager.getSessionToken(getActivity());
if(sessionToken==null){
主要活动。启动信号(ctx);
}
}
受保护的布尔doInBackground(对象…填充){
Log.d(“addressList”,addressList.toString());
startZip=addressList.get(0.getPostalCode();
start=(long)c.get(Calendar.DATE);
reRi=RestQuery.rideSearch(sessionToken,deviceId,startZip,20,null,0,start,start);
如果(!(reRi==null)){
ri=reRi.getRides();
如果(!(ri==null)){
rides=ri.toArray(新的Ride[ri.size()]);
如果(!(骑乘==null)){
对于(int x=0;x
}xml:
我想你需要打电话:
adapter.notiftyDataSetChanged();
更新列表内容之后
试试看,如果有帮助请告诉我
如果您想发布代码的其余部分(封闭的If,启动异步任务的地方),我可以提供更多注释。Hi,该方法不起作用。我发布了代码的其余部分。当你使用这种方法时,你会得到什么?我怀疑从错误的线程访问UI是个例外。
<ViewSwitcher
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/browse_fragment_switcher"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center" >
<TextView
android:id="@+id/sup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Finding possible rides"
android:textSize="25sp"/>
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="@+id/llCollection"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation = "vertical">
<ListView
android:id="@+id/show_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<TextView
android:id="@+id/yo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No rides could be found at this time"
android:textSize="25sp"/>
</LinearLayout>
</ViewSwitcher>
adapter.notiftyDataSetChanged();