Cách sử dụng ListView với nhiều sự lựa chọn. Sử dụng với layout ListView đã được hỗ trợ sẵn.
Các bạn hoàn toàn có thể custom lại ListView với nhiều sự lựa chọn tùy vào ngữ cảnh của ứng dụng.
Dễ dàng nhất là chúng ta sử dụng các tài nguyên đã được xây dựng sẵn.
Code :
public class MutilChoiseListViewActivity extends Activity {
private ListView choiceLV;
private String[] choice = { "String A", "String B", "String C", "String D" };
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
choiceLV = (ListView) findViewById(R.id.list);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_multiple_choice, choice);
choiceLV.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
choiceLV.setAdapter(adapter);
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</LinearLayout>
Đăng ký:
Đăng Nhận xét (Atom)
Bản beta đầu tiên
Sau 6 tháng cả team cặm cụi làm việc điên cuồng, bản alpha cũng được giới thiệu ra toàn bộ công ty và được testing nội bộ công ty mà thôi. ...
-
Language : Java. Version 1.0.0 Write by Sungha References code on the internet Source code : http://www.mediafire.com/?ec7632r731me7vv...
-
Code : http://www.mediafire.com/?z24113j1jzn8kaf
-
Sau 6 tháng cả team cặm cụi làm việc điên cuồng, bản alpha cũng được giới thiệu ra toàn bộ công ty và được testing nội bộ công ty mà thôi. ...
Trời ơi,cảm ơn Đại Ca nhiều lắm :D em đang tìm cách tạo ListView với extends Activity
Trả lờiXóa