0
我創建了一個EditText
,它將在單擊GridView
中的某個項目時顯示爲對話框。我的基本目的是用戶可以點擊一天添加事件,事件詳細信息將出現在日曆上。將數據從對話框中的edittext傳遞到適配器android
這是我的代碼:
calendarview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v, final int pos,
long id) {
tvEvent = (TextView)v.findViewById(R.id.tvEvent) ;
Builder builder = new AlertDialog.Builder(CalendarViews.this);
builder.setIcon(R.drawable.ic_launcher);
builder.setTitle("Enter the event details");
edEvent = new EditText(CalendarViews.this);
LinearLayout.LayoutParams tbLayout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
edEvent.setLayoutParams(tbLayout);
builder.setView(edEvent);
builder.setPositiveButton("Set",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
eventDetails = edEvent.getText().toString();
String event[]= new String[34];
tvEvent.setText(event[pos]); //if pos = 5 , then text added to 5 position of all months
}
});
如何避免文本被添加到該所有個月?
任何人都可以請建議一個解決方案? – Siju