More improvements to pager.
Also another size step for the resource screen size sample. Change-Id: I9e8b63d2fc9a0ceab7b003f7bd75218b78311ed6
This commit is contained in:
83
samples/ApiDemos/res/layout-h974dp/resources_height.xml
Normal file
83
samples/ApiDemos/res/layout-h974dp/resources_height.xml
Normal file
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2011 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- Part of resources_width_and_height that varies based on height. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
83
samples/ApiDemos/res/layout-w1024dp/resources_width.xml
Normal file
83
samples/ApiDemos/res/layout-w1024dp/resources_width.xml
Normal file
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2011 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- Part of resources_width_and_height that varies based on width. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w1024dp Width\n#1">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w1024dp Width\n#2">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w1024dp Width\n#3">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w1024dp Width\n#4">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w1024dp Width\n#5">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w1024dp Width\n#6">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w1024dp Width\n#7">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w1024dp Width\n#8">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w1024dp Width\n#9">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w1024dp Width\n#10">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w1024dp Width\n#11">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w1024dp Width\n#12">
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
@@ -28,10 +28,17 @@
|
||||
android:layout_weight="1">
|
||||
</android.support.v4.app.FragmentPager>
|
||||
|
||||
<Button android:id="@+id/new_fragment"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:text="@string/new_fragment">
|
||||
<requestFocus />
|
||||
</Button>
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:gravity="center" android:measureWithLargestChild="true"
|
||||
android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||
android:layout_weight="0">
|
||||
<Button android:id="@+id/goto_first"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:text="@string/first">
|
||||
</Button>
|
||||
<Button android:id="@+id/goto_last"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:text="@string/last">
|
||||
</Button>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -175,6 +175,8 @@
|
||||
<string name="fragment_stack_support">Support/App/Fragment/Stack</string>
|
||||
|
||||
<string name="fragment_pager_support">Support/App/Fragment/Pager</string>
|
||||
<string name="first">First</string>
|
||||
<string name="last">Last</string>
|
||||
|
||||
<string name="loader_cursor">App/Loader/Cursor</string>
|
||||
|
||||
|
||||
@@ -40,26 +40,28 @@ public class FragmentPagerSupport extends FragmentActivity
|
||||
static final int NUM_ITEMS = 10;
|
||||
|
||||
FragmentPager mPager;
|
||||
int mCurPos;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.fragment_pager);
|
||||
setContentView(R.layout.fragment_pager_support);
|
||||
|
||||
mPager = (FragmentPager)findViewById(R.id.pager);
|
||||
mPager.setAdapter(this);
|
||||
|
||||
Button button;
|
||||
|
||||
// Watch for button clicks.
|
||||
Button button = (Button)findViewById(R.id.new_fragment);
|
||||
button = (Button)findViewById(R.id.goto_first);
|
||||
button.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mCurPos++;
|
||||
if (mCurPos < NUM_ITEMS) {
|
||||
mPager.setCurrentItem(mCurPos);
|
||||
} else {
|
||||
mCurPos--;
|
||||
}
|
||||
mPager.setCurrentItem(0);
|
||||
}
|
||||
});
|
||||
button = (Button)findViewById(R.id.goto_last);
|
||||
button.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mPager.setCurrentItem(NUM_ITEMS-1);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -108,7 +110,7 @@ public class FragmentPagerSupport extends FragmentActivity
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_pager_list, container, false);
|
||||
View v = inflater.inflate(R.layout.fragment_pager_support_list, container, false);
|
||||
View tv = v.findViewById(R.id.text);
|
||||
((TextView)tv).setText("Fragment #" + mNum);
|
||||
return v;
|
||||
|
||||
Reference in New Issue
Block a user