English 中文(简体)
Android 异构体
原标题:Android Spinner adapting an array with unknown elements
  • 时间:2012-01-13 18:48:08
  •  标签:
  • android

我正在建造一些精子,其中载有我从一份文件中总结的信息。 因此,我决定使pin子适应一个阵列。 如果我开始这样一阵:

String [] TEST = {"one", "two", "three"} and pass this string here:

ArrayAdapter<String> numAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, TEST); 

一切产品都进行罚款。 BUT,因为我不一定知道什么会进入主轴,我有一位教长(这名教官正确说话,并储存着阵列中的信息),这造成方案在我把阵列通过阿雷拉Adapter时坠毁。 我通过建造一个像样的简便阵列来测试它:

for(int i = 0; i < 6; i++){
        test[i] = {"hi"};
    }

以及DOESN T工作。 为什么会这样做?

问题回答

No curley braces while assigning value, as well as you need to initiate array with size before using it. Here is example code. But this code will populate "hi" 6 times.

String[] test = new String[6];
for(int i = 0; i < 6; i++){
        test[i] = "hi";
    }




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签