Please help me to retrive spinner hint from database as i am totally new with android. My code is given below.
enter code here
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login);
getid();
setListner();
List<String> list = new ArrayList<String>();
list.add("string1");
list.add("string2");
list.add("string3");
list.add("[Select one]");
final int listsize = list.size() - 1;
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, list) {
@Override
public int getCount() {
return(listsize); // Truncate the list
}
};
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spSelectName.setAdapter(dataAdapter);
spSelectName.setSelection(listsize); // Hidden item to appear in the spinner
}
private void setListner() {
try {
btnLogin.setOnClickListener(this);
} catch (Exception e) {
e.printStackTrace();
}
}
private void getid() {
try {
tvMacAddress =(TextView)findViewById(R.id.tvMacAddress);
spSelectName =(Spinner)findViewById(R.id.spSelectName);
edtPassword =(EditText)findViewById(R.id.edtPassword);
btnLogin =(Button)findViewById(R.id.btnLogin);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onClick(View v) {
switch (v.getId())
{
case R.id.btnLogin :
Intent intent = new Intent(this,Interview.class);
startActivity(intent);
break;
}
}
}
Aucun commentaire:
Enregistrer un commentaire