2013年7月19日星期五

@ android: id / list and @ + id / android: list What is the difference?

There is a small program interpretation
public class ListActivityTest extends ListActivity
{
@ Override
public void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);

String [] arr = {"Monkey King", "Pig", "monk"};
ArrayAdapter <String> adapter = new ArrayAdapter <String> (this,
android.R.layout.simple_list_item_multiple_choice, arr);
/ / Set the window display list
setListAdapter (adapter);
}
}


main.xml is this
<? xml version = "1.0" encoding = "utf-8"?>
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
android: orientation = "vertical"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
>
<ListView android: id = "@ + id / android: sad"
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: background = "# 0000ff"
android: layout_weight = "1"
android: drawSelectorOnTop = "false" />
</ LinearLayout>

Why ListView android: id = "@ + id / android: sad" so run successfully
Should not write @ + id / android: list do?
I do not even write android: id This attribute can be run.
-------------------------------------------------
I know it. . Missed a setContentView (R.layout.main);

But using @ android: id / list instead of @ + id / android: list why go wrong? What is the difference

-------------------------------------------------
You are using a ListActivity
The only recognize the android: list
-------------------------------------------------
Upstairs said is, if you just inherited Activity, to find their own listview, it just defines id
-------------------------------------------------
+ id said that if it is not the id, the definition of an id

没有评论:

发表评论