Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 进度对话框未显示_Android_Progressdialog - Fatal编程技术网

Android 进度对话框未显示

Android 进度对话框未显示,android,progressdialog,Android,Progressdialog,我有两个纺纱厂,一个叫烹饪,另一个叫区域。我正在调用新的任务()。以“init”作为参数在活动加载时执行。在这一点上,微调器应该从webservice设置,其中包含可用的菜系和区域列表(此处不包括此方法)。最初,微调器将选择“全部”,因此listview“restaurantlist”应该包含所有餐厅。当用户从微调器更改菜肴或区域时,restaurantlist listview应该更新,并显示一个progressdialog。 现在我的问题是,所有代码都在工作,但是在填充listview之后,

我有两个纺纱厂,一个叫烹饪,另一个叫区域。我正在调用新的任务()。以“init”作为参数在活动加载时执行。在这一点上,微调器应该从webservice设置,其中包含可用的菜系和区域列表(此处不包括此方法)。最初,微调器将选择“全部”,因此listview“restaurantlist”应该包含所有餐厅。当用户从微调器更改菜肴或区域时,restaurantlist listview应该更新,并显示一个progressdialog。 现在我的问题是,所有代码都在工作,但是在填充listview之后,progressdialog开始显示,并且progressdialog在按下“后退”按钮之前从未停止。任何解决方案都将是gr8帮助。 提前谢谢

公共类任务扩展异步任务 {

     String flagdopost="",x,y;       
     @Override 
     public void onPreExecute() 
     {   
        pg =new ProgressDialog(Restaurantlistdisplay.this);
        pg.setMessage("fetching info....");
        pg.setIndeterminate(true);
        pg.setCancelable(true);
        Log.i("inside preexecute","in pre execute");
        pg.show();

     }   

     public Void doInBackground(String... params)
     {          
        if(params[0].equalsIgnoreCase("init"))
        {
            tempcuisinenamelist = getCuisines();    
            tempcuisinenamelist.add(0,"All");

            tempareanamelist=getAreanames(cid, sid, cityid);
            tempareanamelist.add(0,"All");

            flagdopost="init";  
            Log.i("inside doinbackground 1st",flagdopost);
        }

        else if(params[0].equalsIgnoreCase(""))
        {
            firequery();
            flagdopost="itemselected";
            Log.i("inside doinbackground 2nd",flagdopost);
        }
        else if(params[0].equalsIgnoreCase("itemclick"))
        {
            //sendid=getRestaurantId(params[1],params[2]);  
            x=params[1];
            y=params[2];
            Log.i("in do in backgroung idforbundle is", Integer.toString(sendid));
            flagdopost="itemclicked";
        }
        return null;                     
     } 

    public void onPostExecute(Void result)
     {       
        if(flagdopost.equalsIgnoreCase("init"))
        {
            ArrayAdapter<String> adaptercuisine=new                           ArrayAdapter<String> (Restaurantlistdisplay.this,android.R.layout.simple_spinner_item,tempcuisinenamelist);
            adaptercuisine.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

            ArrayAdapter<String> adapterarea=new ArrayAdapter<String>(Restaurantlistdisplay.this,android.R.layout.simple_spinner_item,tempareanamelist);
            adapterarea.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

            area.setAdapter(adapterarea); 
            area.setSelection(0);
            area.setOnItemSelectedListener(Restaurantlistdisplay.this);
            cuisine.setAdapter(adaptercuisine); 
            cuisine.setSelection(0);
            cuisine.setOnItemSelectedListener(Restaurantlistdisplay.this);

        }
        else if(flagdopost.equalsIgnoreCase("itemselected"))
        {
            getResult(str);
            customlist.clear();
            populateReslist();
            //Log.i("inside 1st firequery","list populated"+customlist.toString());

            restaurant.invalidateViews();
            restaurant.setAdapter(new SimpleAdapter(Restaurantlistdisplay.this,customlist,R.layout.customlistrow,new String[] {"Restaurant Name","Area Name"},
                    new int[] {R.id.tvresname,R.id.tvareaname})
                    {
                   @Override      
                   public View getView(int position, View convertView,ViewGroup parent)
                   {           
                       View view =super.getView(position, convertView, parent); 
                       return view;       
                   }  
                 });

         }
        else if(flagdopost.equalsIgnoreCase("itemclicked"))
        {               
            sendid=getRestaurantId(x,y);
            Bundle bundle=new Bundle();
            bundle.putInt("locid",sendid);
            Toast.makeText(getBaseContext(), "locId in dopost new one"+sendid, 10).show();

            Intent resdetail = new Intent(Restaurantlistdisplay.this,Restaurantdetail.class);
            resdetail.putExtras(bundle);
            startActivity(resdetail);

        }   
         pg.dismiss();
     }  
 }

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
        long arg3) 
{
    switch(arg0.getId())
    {
        case R.id.spncuisine:                                           asynctaskflag="";
                if(cuisine.getSelectedItem().toString()!="All")
                                {
                            cuisineval=cuisine.getSelectedItem().toString();
                        }
                else
                {
                    cuisineval="*";
                }
                new Thetask().execute(asynctaskflag,null,null);
                break;

        case R.id.spnarea:                  
                asynctaskflag="";
                if(area.getSelectedItem().toString()!="All")
                {
                    areaval=area.getSelectedItem().toString();
                }
                else
                {
                    areaval="*";
                }
                new Thetask().execute(asynctaskflag,null,null);
                break;
    }   

}
public void onNothingSelected(AdapterView<?> arg0) {
    // TODO Auto-generated method stub

}
}
String flagdopost=“”,x,y;
@凌驾
公共无效onPreExecute()
{   
pg=新建进度对话框(Restaurantlistdisplay.this);
pg.setMessage(“获取信息…”);
pg.setUndeterminate(真);
pg.setCancelable(真);
Log.i(“内部预执行”、“预执行中”);
pg.show();
}   
公共Void doInBackground(字符串…参数)
{          
if(参数[0].equalsIgnoreCase(“init”))
{
tempcuisinenamelist=getCuisines();
临时菜系名称列表。添加(0,“全部”);
tempareanamelist=getAreanames(cid、sid、cityid);
tempareanamelist。添加(0,“全部”);
flagdopost=“init”;
Log.i(“内部doinbackground第一”,Flagdost);
}
else if(参数[0].equalsIgnoreCase(“”)
{
firequery();
flagdost=“itemselected”;
Log.i(“第二个室内后台”,Flagdost);
}
else if(参数[0].equalsIgnoreCase(“itemclick”))
{
//sendid=getRestaurantId(参数[1],参数[2]);
x=参数[1];
y=参数[2];
Log.i(“背景中的do-in-backgroung-idforbundle是”,Integer.toString(sendid));
flagdost=“itemclicked”;
}
返回null;
} 
PostExecute上的公共作废(作废结果)
{       
if(flagdopost.equalsIgnoreCase(“init”))
{
ArrayAdapter adaptercuisine=新的ArrayAdapter(Restaurantlistdisplay.this,android.R.layout.simple\u spinner\u item,tempcuisinenamelist);
adaptercuisine.setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
ArrayAdapter adapterarea=新的ArrayAdapter(Restaurantlistdisplay.this,android.R.layout.simple\u spinner\u项,tempareanamelist);
adapterarea.setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
区域。设置适配器(适配器区域);
面积(0);
setOnItemSelectedListener(Restaurantlistdisplay.this);
烹调法:setAdapter(adaptercuisine);
饮食,选举(0);;
美食。SetonimSelectedListener(Restaurantlistdisplay.this);
}
else if(flagdopost.equalsIgnoreCase(“itemselected”))
{
获取结果(str);
customlist.clear();
populateResist();
//Log.i(“在第一个firequery内部”,“填充列表”+customlist.toString());
restaurant.invalidateViews();
setAdapter(新的SimpleAdapter(Restaurantlistdisplay.this,customlist,R.layout.customlistrow,新字符串[]{“餐厅名称”,“区域名称”},
新int[]{R.id.tvresname,R.id.tvareaname})
{
@凌驾
公共视图getView(int位置、视图转换视图、视图组父视图)
{           
视图=super.getView(位置、转换视图、父级);
返回视图;
}  
});
}
else if(flagdopost.equalsIgnoreCase(“itemclicked”))
{               
sendid=getRestaurantId(x,y);
Bundle=新Bundle();
bundle.putInt(“locid”,sendid);
Toast.makeText(getBaseContext(),“dopost new one中的locId”+sendid,10.show();
Intent resdetail=newintent(Restaurantlistdisplay.this,Restaurantdetail.class);
resdetail.putExtras(bundle);
星触觉(细节);
}   
第()页;
}  
}
已选择公共视图(适配器视图arg0、视图arg1、内部arg2、,
长arg3)
{
开关(arg0.getId())
{
案例R.id.spncuisine:asynctaskflag=“”;
if(courine.getSelectedItem().toString()!=“全部”)
{
cuisineval=cuisine.getSelectedItem().toString();
}
其他的
{
cuisineval=“*”;
}
新建任务().execute(asynctaskflag,null,null);
打破
案例R.id.spnarea:
asynctaskflag=“”;
如果(area.getSelectedItem().toString()!=“全部”)
{
areaval=area.getSelectedItem().toString();
}
其他的
{
areaval=“*”;
}
新建任务().execute(asynctaskflag,null,null);
打破
}   
}
未选择公共无效(AdapterView arg0){
//TODO自动生成的方法存根
}
}
//根据大家的要求,getCuisines()的代码如下所示。C如果这有帮助的话

public List<String> getCuisines()
 {
        String list = null;
        cuisinelist=new ArrayList<String>();
    try
    {
       SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
       request.addProperty("str", //here goes query to fetch data from table of </br>cuisines);   
       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);      
    HttpTransportSE aht = new HttpTransportSE(URL);     
    aht.debug = true;
    aht.call(SOAP_ACTION, envelope);
    SoapPrimitive results = (SoapPrimitive)envelope.getResponse();
        list=results.toString();
      }
      catch (SocketException ex)
      {  
    ex.printStackTrace();
      }
     catch (Exception e)
     {         
    e.printStackTrace(); 
      } 
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
try
{
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document dom = builder.parse(new InputSource(new StringReader(list))); 
    Element root = dom.getDocumentElement();
    NodeList items = root.getElementsByTagName("row");
    for (int i=0;i<items.getLength();i++)
    {
       Node item = items.item(i);
       NodeList properties = item.getChildNodes();
       for (int j=0;j<properties.getLength();j++)
       {
            Node property = properties.item(j);
        String name = property.getNodeName();
        if (name.equalsIgnoreCase("typeName"))
        {
                   cuisinelist.add(property.getFirstChild().getNodeValue());
        }                       
        }
    }
    return cuisinelist;         
  }
  catch (Exception e) 
  {
    throw new RuntimeException(e);
      } 
public List getCuisines()
{
字符串列表=空;
菜谱列表=新的ArrayList();
尝试
{
SoapObject请求=新的SoapObject(名称空间、方法名称);
request.addProperty(“str”,//下面是从选项卡获取数据的查询
 if(pg.isShowing())
{
pg.dismiss();
}
  ProgressDialog dialogGoog = new ProgressDialog(getParent());