2012-01-15 39 views
0

请帮我使用此代码: 每次只有其他情况下执行不是如果我有资产/ www文件夹中的html文件,这是列表视图
在这里,我提供ListviewActivity我将有最多20在这个列表中,每个列表将有一个webview每次只有“else case alert dialog”正在调用?

//这是列表视图中的数据 private String arr [] = {“sunny”,“cool”,“hot”,“rainy”}; list.setOnItemClickListener(新OnItemClickListener(){

 public void onItemClick(AdapterView<?> arg0, View arg1, int position, 
     long arg3) { 
      /*Intent myIntent = new Intent(SpellsActivity.this, Details.class); 

      myIntent.putExtra("key",(String) list.getItemAtPosition(position)); 
      startActivity(myIntent);*/ 
      String str =(String) list.getItemAtPosition(position); 
      Context mContext= SpellsActivity.this; 
      AlertDialog.Builder alert = new AlertDialog.Builder(mContext); 



      //this is where i need you to see only else case is invoking not the if  

      if(str.equalsIgnoreCase(arr[0])){ 
      alert.setTitle("Sunny"); 
      WebView wv=new WebView(mContext); 
      wv.loadUrl("file:///android_asset/www/sunny.html"); 
      } 
      else{ 
       alert.setTitle("Cool"); 
       WebView wv=new WebView(mContext); 
       wv.loadUrl("file:///android_asset/www/cool.html");*/ 
      } 


      alert.setView(wv); 
      alert.setIcon(R.drawable.ic_launcher); 
      alert.setPositiveButton("Back", 
       new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int id) { 
       Toast.makeText(getApplicationContext(), "BACK", Toast.LENGTH_SHORT).show(); 
       } 
       }); 

      alert.show(); 
     } 

    }); 

} 

} 

为了测试是否是工作或没有我刚才所用的两种选择晴天或其他

+0

对不起朋友得到的答案,但无法发布,因为较少的声誉将在6小时后发布 – VENKI 2012-01-15 14:02:58

回答

0

对不起,朋友,它不是像,如果没有被调用,但网络视图在如果子句未被执行,因为对象

AlertDialog.Builder alert = new AlertDialog.Builder(mContext); 
      WebView wv=new WebView(mContext); 
      if(str.equalsIgnoreCase(arr[0])){ 
      alert.setTitle("if"); 
       wv.loadUrl("file:///android_asset/www/sunny.html"); 
      } 
      else{ 
       alert.setTitle("else"); 

       wv.loadUrl("file:///android_asset/www/cool.html"); 
      } 

现在它是完美的。

0

请提供有关数据,你一点更多的代码正在用来设置你的列表视图。可能有数据的差异导致执行条件的其他部分..

+0

我会发布整个代码等待 – VENKI 2012-01-15 13:14:19

相关问题