Android JSON ListView不是';提神

Android JSON ListView不是';提神,android,arrays,json,listview,Android,Arrays,Json,Listview,我有带JSON Listview的android应用程序,我有单选按钮,当我选择其中任何一个时,JSON文件的链接将被更改,但不会更改,这是我的代码(知道字符串cat是链接中的更改): /*@#######JSON项目列表视图###*/ listView=(listView)findViewById(R.id.itemsLayoutList); adapter=新的CustomListAdapterZ(此,movieList); setAdapter(适配器); pDialog=新建进度对话框(

我有带JSON Listview的android应用程序,我有单选按钮,当我选择其中任何一个时,JSON文件的链接将被更改,但不会更改,这是我的代码(知道字符串cat是链接中的更改):

/*@#######JSON项目列表视图###*/
listView=(listView)findViewById(R.id.itemsLayoutList);
adapter=新的CustomListAdapterZ(此,movieList);
setAdapter(适配器);
pDialog=新建进度对话框(此对话框);
//在发出http请求之前显示进度对话框
设置消息(“加载…”);
pDialog.show();
if(rd1.isChecked())
{
cat=“起动机”;
}
else if(rd2.isChecked())
{
cat=“甜点”;
}
else if(rd3.isChecked())
{
cat=“饮料”;
}
else if(rd4.isChecked())
{
cat=“开放式自助餐”;
}
//创建截击请求对象
JsonArrayRequest movieReq=新的JsonArrayRequest(
"http://users.abdullahadhaim.com/users/WebServiceResturant.asmx/getFoodItems?categoryName="
+cat,新的Response.Listener(){
@凌驾
公共void onResponse(JSONArray响应){
Log.d(TAG,response.toString());
hidePDialog();
//解析json
对于(int i=0;i
您可以尝试:

// notifying list adapter about data changes
// so that it renders the list view with updated data
adapter.clear();
adapter.addAll(movieList);
adapter.notifyDataSetChanged();
祝你成功

movieList.clear();
movieList.addAll(movie);
adapter.notifyDataSetChanged();
希望它能解决您的问题,

使用单选按钮时使用单选组改进代码

方法clear()未定义,我使用的适配器扩展了baseAdapter@YahyaZakariya我假设您正在扩展
ArrayAdapter
。您必须自行调试和检查。请粘贴
CustomListAdapterZ
code方法clear()未定义,我正在使用一个扩展baseAdapteruse clear()方法的适配器,用于movieList not adapter,List有clear方法当我更改它时,它将两个URL合并到一个列表中我不知道您更改了什么??url或列表有问题吗
movieList.clear();
movieList.addAll(movie);
adapter.notifyDataSetChanged();