我的佈局是這樣的:每行可點擊像android鬧鐘一樣的可點擊佈局?
---------------------------
stuff from database
---------------------------
next entry from database
---------------------------
next entry
--------------------------
我喜歡做的是:觀「從數據庫的東西」是要對鬧鐘時間等信息報警第一部分熄滅,它可以點擊,部分視圖的開啓也是可點擊的,但是應該能夠從同一行的旁邊的行中獲取信息,因爲它需要信息,比如說警報ID。我該如何做?
stuff from database | turn on
--------------------------------------
next entry from database | turn on
--------------------------------------
next entry | turn on
---------------------------------------
這是代碼我有:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget38"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:orientation="vertical" >
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textSize="25sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp" />
<TextView
android:id="@+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" - "
android:textSize="30sp" />
<TextView
android:id="@+id/text4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp" />
<CheckBox
android:text=""
android:id="@+id/list_checkbox"
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:focusable="false"
android:focusableInTouchMode="false"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/text5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
更新
public void addListenerOnButton() {
final ToggleButton toggleButton1 = (ToggleButton) findViewById(R.id.toggleButton1);
//toggleButton2 = (ToggleButton) findViewById(R.id.toggleButton2);
Button btnDisplay = (Button) findViewById(R.id.toggleButton1);
btnDisplay.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// StringBuffer result = new StringBuffer();
// result.append("toggleButton1 : ").append(toggleButton1.getText());
// result.append("\ntoggleButton2 : ").append(toggleButton1.getText());
// Toast.makeText(MyAndroidAppActivity.this, result.toString(),
//Toast.LENGTH_SHORT).show();
}
});
}
我用噸
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
databaseHelper = new DatabaseStore(this);
databaseHelper.open();
ListViewData();
registerForContextMenu(getListView());
}
private void ListViewData(){
Cursor MainPageCursor = databaseHelper.fetchAllReminders();
startManagingCursor(MainPageCursor);
String[] empty = new String[] { DatabaseStore.MUTE_TITLE, DatabaseStore.START_KEY_TIME, DatabaseStore.END_KEY_TIME, DatabaseStore.COVERT_DAYS };
int[] notempty = new int[]{R.id.text1,R.id.text2, R.id.text4, R.id.text5};
SimpleCursorAdapter mainPageList = new SimpleCursorAdapter(this, R.layout.editinfo_row,MainPageCursor, empty, notempty);
setListAdapter(mainPageList);
}
protected void onListItemClick(ListView l, View v, int position, long id){
super.onListItemClick(l, v, position, id);
Intent i = new Intent(this, AddTimeEntry.class); /// fix this back to wha tit was
i.putExtra(DatabaseStore.kEY_ROWID, id);
startActivityForResult(i, ACTIVITY_EDIT);
}
editinfo_tow.xml上面的帽子代碼和我得到空指針異常?
可以使用切換按鈕? – Shrikant
非常感謝我從來沒有新的內置到Android ..我只需要現在看它,看看如何去做 – Michael
我在做類似的東西這裏! http://stackoverflow.com/questions/13523350/android-alarm-clock-ui – toobsco42