0
如何通過btnup提交微調selecteditem文本,爲什麼選擇報告btnup的情況下聲明沒有使用?我有足夠的搜索來解決這個問題,但我仍然blankon我需要做的順序在微調器上獲取文本以適應編碼。如何發送空字符串使用微調在Android
UserLocalStore userLocalStore;
EditText etName, etAge, etUsername, uploadImageName;
Button bLogout;
ImageView viewImage;
Button b,btnup;
private String selectedReport = null;
} private void createSpinnerDropDown() {
//get reference to the spinner from the XML layout
Spinner spinner = (Spinner) findViewById(R.id.spinner);
//Array list of report to display in the spinner
List<String> list = new ArrayList<String>();
list.add("Crime");
list.add("Bribery");
list.add("Schools problem");
list.add("Homeless");
list.add("Rural Problems");
list.add("Public Transport");
//create an ArrayAdaptar from the String Array
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(dataAdapter);
spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
}
public class MyOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
String selectedItem = parent.getItemAtPosition(pos).toString();
switch (parent.getId()) {
case R.id.spinner:
if (selectedReport != null) {
Toast.makeText(parent.getContext(), "Report you select is " + selectedItem,
Toast.LENGTH_LONG).show();
}
selectedReport = selectedItem;
break;
}
}
public void onNothingSelected(AdapterView<?> parent) {
// Do nothing.
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bLogout:
userLocalStore.clearUserData();
userLocalStore.setUserLoggedIn(false);
Intent loginIntent = new Intent(this, Login.class);
startActivity(loginIntent);
break;
case R.id.btnup:
Bitmap image = ((BitmapDrawable) viewImage.getDrawable()).getBitmap();
new UploadImage(image, uploadImageName.getText().toString()).execute();
Spinner spinner = (Spinner)findViewById(R.id.spinner);
String selectedReport = spinner.getSelectedItem().toString();
break;
}
}
什麼是解釋? @Hussein El Feky –
我看到你已經添加onClick方法,但是你沒有添加一個監聽器到你的按鈕。所以我解決了。 –
我有聽衆在我的編碼,只是我抹去了他們所以說我沒什麼好說的,因爲它的所有編碼 –