String Array未显示预期值

时间:2012-02-29 12:01:55

标签: java android

我有一个全局初始化的String数组,如:

String[] links={""};

在onclick监听器中,我使用for循环

将一些值放入其中
links = new String[Link.size()];
String[] news = new String[Catagory.size()];
for (int k = 0; k < Catagory.size(); k++) {

    news[k] = Catagory.get(k).toString();

    if (news[k].contentEquals("Android Apps")) {
        links[k] = Link.get(k).toString();
        Toast.makeText(getApplicationContext(), links[k],
                       Toast.LENGTH_LONG).show();
        SHOW.add("Title:" + "\n" + Title.get(k) + "\n"
                 + "Date:" + "\n"
                 + PubDate.get(k).replace("+0000", "") + "\n"
                 + "Content:" + "\n"
                 + Content.get(k).replace("<br/>", "") + "\n");
        Log.i("IF ELSE", Catagory.get(k));
    }
}

正确发生。但是当我在onitemclick侦听器方法中调用此数组时,它再次显示为Blank:

public void onItemClick(AdapterView<?> a, View v, int position, long id) {
    Toast.makeText(getApplicationContext(), links[position], Toast.LENGTH_LONG).show();
}

如何获得我在onclick监听器中拥有的数组值?

0 个答案:

没有答案