消えゆく世界と流れる未来に最後の灯を since 2006/4/3
package com.example.listFragmentTest;
import com.example.listFragmentTest.R;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
<!--?xml version="1.0" encoding="utf-8"?-->
<linearlayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<fragment
android:id="@+id/list_parent"
android:layout_height="match_parent/"
android:layout_weight="1"
android:layout_width="0dp"
class="com.example.listFragmentTest.ItemListFragment">
</fragment>
</linearlayout>
package com.example.listFragmentTest;
import com.example.listFragmentTest.R;
import android.app.ListFragment;
import android.os.Bundle;
import android.widget.ArrayAdapter;
public class ItemListFragment extends ListFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ArrayAdapter adapter =
ArrayAdapter.createFromResource(
getActivity(),
R.array.list,
android.R.layout.simple_list_item_1);
setListAdapter(adapter);
}
}
<!--?xml version="1.0" encoding="utf-8"?-->
<linearlayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<fragment
android:id="@+id/list_child"
class="com.example.listFragmentTest.ItemListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</fragment>
</linearlayout>
<!--?xml version="1.0" encoding="utf-8"?-->
<resources>
<string name="app_name">
listFragmentTest
</string>
<string name="action_settings">
Settings
</string>
<string-array name="list">
<item>a</item>
<item>b</item>
<item>c</item>
<item>d</item>
</string-array>
</resources>