English 中文(简体)
• 如何利用休息时间铺设警戒线,并将其用作清单
原标题:How to use a while loop to build a stringarray and use it as a list
  • 时间:2012-01-13 03:39:41
  •  标签:
  • java
  • android

我为同学学生写了一封信,我正在一个网站上发布信息。 我花了一张gu子来写大话,但工作做得很差,他想获得更多钱帮助。 因此,试图自行解决这一问题。

抽取者认为, gr鱼是主人。 java就是如此。

      Content1 = extractor.BusRoutes.get(1);
      Content2 = extractor.BusRoutes.get(2);
      Content3 = extractor.BusRoutes.get(3);

但是,有30多辆公共汽车,对我来说,这不是一个牢固的想法。 因此,我试图同时进行 lo和阵列,以便编制清单,使之成为一份roid名单。

 public class BusRoutes extends ListActivity   {

TransitXMLExtractor extractor;


public String[] busroutearray()
{
    extractor = new TransitXMLExtractor();
    String[] busroutearray = new String[40];    
    int n = 0;
    while(n != (busroutearray.length - 1)){
    busroutearray[n] = extractor.BusRoutes.get(n);
    n++;
}
return busroutearray;
}








/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setListAdapter(new ArrayAdapter<String>(this,      android.R.layout.simple_list_item_1, busroutearray()));
    getListView().setTextFilterEnabled(true);
}

当汽车发射时,总会被迫放弃。

此前,N++已经停下来,但在修改法典时却被删除,但只有N++,其效果仍然相同。

最佳回答

你需要增加你的反响(n)。 因此,法典是:

while (n != (busroutearray.length - 1)) {
    busroutearray[n] = extractor.BusRoutes.get(n);
    n++;
}

如果你只是想通过下列方式加以振兴的话,那将更有利于 lo(更便于阅读和理想:

for (int i = 0; n < busroutearray.length; i++) {
    busroutearray[i] = extractor.BusRoutes.get(i);
}

您也不妨探讨使用比阵列更为灵活的不同数据结构(example )。

问题回答

问题在于你。 由于你没有改变“n”价值,它正在 lo中。

    public String[] busroutearray()
    {
        extractor = new TransitXMLExtractor();
        String[] busroutearray = new String[40];    
        int n = 0;

        for (int n = 0; n < busroutearray.length; n++){
           busroutearray[n] = extractor.BusRoutes.get(n);
        }

    }

您并不是在<代码>n上加固的,它是一种无限的漏洞。 And Anders prolly threw a ANR (Application not Response).

int n = 0;
while(n < busroutearray.length){
    busroutearray[n] = extractor.BusRoutes.get(n);
    n++;
}

虽然我并不肯定,但我想BusRoutes 是<代码>List的一部分。

Why don t you use,

String[] busroutearray = extractor.BusRoutes.toArray(new String[extractor.BusRoutes.size()]);




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签