Как установить текст динамического созданного флажки из определенной пользовательской переменнойAndroid

Форум для тех, кто программирует под Android
Anonymous
Как установить текст динамического созданного флажки из определенной пользовательской переменной

Сообщение Anonymous »

У меня есть этот код: < /p>

package com.app.BoomBase;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;

public class CheckList extends Activity{
ImageButton bAddBoom, bAddTools, bAddCloth, bRemoveBoom, bRemoveTools, bRemoveCloth;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.check_list);
final LinearLayout llBooms = (LinearLayout) findViewById(R.id.llBooms);
ImageButton bAddBoom = (ImageButton) findViewById(R.id.bAddBoom);

bAddBoom.setOnClickListener(new View.OnClickListener() {

@SuppressWarnings("deprecation")
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
AlertDialog alert = new AlertDialog.Builder(CheckList.this).create();
final EditText input = new EditText(CheckList.this);
alert.setTitle("Name of category?");
alert.setView(input);
alert.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String userin = input.getText().toString();
if(userin != null){
return;
}
else{
for(int i = 0; i < 1; i++) {
CheckBox cb1 = new CheckBox(getBaseContext());
cb1.setText(userin+i);
cb1.setId(i+1);
llBooms.addView(cb1);
}
}

}
});
alert.show();
alert.setButton("Cancel", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}

});

}
});
}
< /code>

} < /p>

И я не могу понять, как сделать флажок, есть имя переменной «Пользователь» .. может кто -нибудь мне помочь?
Другой вопрос: как я могу обработать недавно созданный флажок в коде, чтобы я мог проверить контент, если он проверяется или нет? < /p>

спасибо! < /p>

Подробнее здесь: https://stackoverflow.com/questions/168 ... d-variable

Вернуться в «Android»