0

如果我的 String value(from) 为空,我想调用不同的活动,反之亦然:

    String[] from = new String[] { "name" };

    if (from.length >= 1)

    {
        int[] to = new int[] { R.id.countryTextView111};
        conAdapter = new SimpleCursorAdapter(CountryList.this, R.layout.countrylist, null, from, to);
        setListAdapter(conAdapter); // set adapter

    }   
    else 

    {

        Intent intent = new Intent(getApplicationContext(), EmailSettings.class);
        startActivity(intent);

    }

出于某种原因,我的 Condition 无法正常工作,因此需要专家视图。

谢谢,

阿里

4

2 回答 2

1

您正在检查数组的长度,它包含一个条目,因此它的长度为1 如果您想检查第一个条目的长度,那么

String[] from = new String[] { "name" };

if (from[0].length >= 1)

{
    int[] to = new int[] { R.id.countryTextView111};
    conAdapter = new SimpleCursorAdapter(CountryList.this, R.layout.emailsettings, null, from, to);
    setListAdapter(conAdapter); // set adapter

}   
else 

{

    Intent intent = new Intent(getApplicationContext(), EmailSettings.class);
    startActivity(intent);

}
于 2012-12-10T11:48:46.493 回答
0
String[] from = new String[] { "name" };

for(int i=0;i<from.length;i++)
   {
      if(from[i]>="conditon")
       {
         //try code this
       }
   }
于 2012-12-10T11:59:29.703 回答