如何使用字符串作爲消息來烘烤onItemClickListener? 我正在製作支持多種語言的應用程序,並且我想在不同的語言上顯示敬酒。爲此,我需要使用字符串。那麼我怎樣才能得到烤麪包串並顯示呢?Toast onItemClickListener使用字符串的消息?
list.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
switch (position) {
case 0:
showtost();
break;
}
return true;
我嘗試了一些方法,但它沒有奏效。
private void showtost() {
// TODO Auto-generated method stub
Toast.makeText(this,
.getResources().getString(R.string.alarm),
Toast.LENGTH_SHORT).show();
return;
}
The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (new AdapterView.OnItemLongClickListener(){},
字符串,INT)
也許添加當前實現的onItemClickListener – donfuxx
U只需在您的應用程序中更改您的區域設置,並從相應的strings.xml中獲取本地化的字符串。 –
我無法理解真正的問題,你需要定義多語言字符串,或者你需要onitemclicklistener烤麪包? –