0
我是編程新手,所以也許這個問題很愚蠢。搜索互聯網,但沒有找到。我需要這樣做,如圖所示。在一行中,添加Label和EditText。請幫幫我。AlertDialog需要一個解決方案
public void onAddExpenseClick(View viev){
final String[] mChoose = getResources().getStringArray(R.array.mChoose);
final EditText input = new EditText(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.addExpensTitle)
.setCancelable(false)
.setView(input)
.setPositiveButton(R.string.addExpensPB, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(input.getText().toString().equals("")) {
Toast.makeText(
getApplicationContext(),
"Enter the correct amount",
Toast.LENGTH_SHORT).show();
return;
}
Expense expense = new Expense();
expense.setType(getTag(mChoose[itemChoosed]).toLowerCase());
expense.setAmount((long)(100 * Double.valueOf(input.getText().toString())));
expense.setDateAndTime(dateValue);
try {
expense.setTripId(((TravelApp)getApplication()).getTripManager().getDefaultTripId());
//Log.d(LOG, expense.toString());
expense.setCurrencyCode(
((TravelApp)getApplication()).getCurrencyManager().getEntranceCurrency()
);
((TravelApp)getApplication()).getExpenseManager().create(expense);
tabFragment.gotoGridView();
} catch (SQLException e) {
e.printStackTrace();
}
}
})
.setNegativeButton(R.string.AdminDialogNB, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
})
.setSingleChoiceItems(mChoose, -1,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int item) {
itemChoosed = item;
}
});
builder.show();
}
僅供參考:您並不需要刪除舊的問題。您可以使用此信息進行編輯。 – codeMagic
謝謝,我會知道 – Sasha