Androidでドロップダウンリストを作成するにはどうすればよいですか
と呼ばれるものを見つけましたList View
スタックオーバーフローでは質問を送信できないため、これらの行を追加します
<tag status="remove" because="can't add question"/>
int i=0; while(i=1;i<4;i++)
system.out.println("sorry");
<?Php
$word="sorry";
echo $word;
?>
コードを追加した後
public class getCellsFromServer extends
AsyncTask<String, Integer, String[]> {
ProgressDialog dialog;
@Override
protected void onCancelled() {
super.onCancelled();
}
@Override
protected void onPostExecute(String[] results) {
super.onPostExecute(results);
final MyData items [] = new MyData[results.length];
for(int i=0;i<results.length;i++){
items[i]= new MyData(results[i],results[i]);
}
ArrayAdapter<MyData> adapter = new ArrayAdapter<MyData>(this,
android.R.layout.simple_spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
dialog = new ProgressDialog(AnswerQuestion.this);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setMax(100);
dialog.show();
}
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
dialog.incrementProgressBy(values[0]);
}
@Override
protected String[] doInBackground(String... params) {
for (int i = 0; i < 20; i++) {
publishProgress(5);
try {
Thread.sleep(88);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
dialog.dismiss();
URI website;
try {
HttpClient client = new DefaultHttpClient();
website = new URI(
"http://10.0.2.2:8080/LocalizedBasedComptitionServer/GetCells");
HttpPost request = new HttpPost();
request.setURI(website);
HttpResponse response = client.execute(request);
ObjectInputStream in = new ObjectInputStream(response.getEntity().getContent()); //Android
String commingArray ="";
int c=0;
c=in.read();
while(c!=-1){
commingArray+=(char)c;
c=in.read();
}
String[] ar = commingArray.split(",");
return ar;
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
class MyData {
public MyData(String spinnerText, String value) {
this.spinnerText = spinnerText;
this.value = value;
}
public String getSpinnerText() {
return spinnerText;
}
public String getValue() {
return value;
}
public String toString() {
return spinnerText;
}
String spinnerText;
String value;
}
}