携帯電話(LG Optimus NET)とGalaxy Miniでアプリケーションをテストしましたが、すべて正常に動作しています。しかし、大画面のデバイスでテストしたい場合、起動時にクラッシュします。S3とAllViewを試してみました(モデルはよくわかりません)。
私のマニフェスト:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.swipefragments"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<supports-screens android:largeScreens="true"
android:normalScreens="true" android:smallScreens="true"
android:resizeable="true" android:anyDensity="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock" >
<activity
android:name="com.example.swipefragments.MainActivity"
android:label="Stiai ca..."
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
主な活動:
public class MainActivity extends SherlockFragmentActivity {
static final int NUM_ITEMS = 550;
MyAdapter mAdapter;
ViewPager mPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(false);
setContentView(R.layout.fragment_pager);
mAdapter = new MyAdapter(getSupportFragmentManager());
mPager = (ViewPager)findViewById(R.id.pager);
mPager.setAdapter(mAdapter);
// Watch for button clicks.
Button button = (Button)findViewById(R.id.goto_first);
// button.getBackground().setColorFilter(0xFF0174DF, PorterDuff.Mode.MULTIPLY);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mPager.setCurrentItem(0);
}
});
button = (Button)findViewById(R.id.goto_last);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mPager.setCurrentItem(NUM_ITEMS-1);
}
});
button = (Button)findViewById(R.id.goto_random);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Random r = new Random();
int i1=r.nextInt(529)+20;
mPager.setCurrentItem(i1);
}
});
button = (Button)findViewById(R.id.goto_about);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Ciuboariu Florin, Ianuarie 2013", Toast.LENGTH_SHORT).show();
}
});
}
public static class MyAdapter extends FragmentPagerAdapter {
public MyAdapter(FragmentManager fm) {
super(fm);
}
@Override
public int getCount() {
return NUM_ITEMS;
}
@Override
public Fragment getItem(int position) {
return ArrayListFragment.newInstance(position);
}
}
public static class ArrayListFragment extends SherlockListFragment {
int mNum;
/**
* Create a new instance of CountingFragment, providing "num"
* as an argument.
*/
static ArrayListFragment newInstance(int num) {
ArrayListFragment f = new ArrayListFragment();
// Supply num input as an argument.
Bundle args = new Bundle();
args.putInt("num", num);
f.setArguments(args);
return f;
}
/**
* When creating, retrieve this instance's number from its arguments.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Random r = new Random();
// int i1=r.nextInt(70-1)+1;
// mNum = i1;
mNum = getArguments() != null ? getArguments().getInt("num") : 1;
}
/**
* The Fragment's UI is just a simple text view showing its
* instance number.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_pager_list, container, false);
View tv = v.findViewById(R.id.text2);
switch(mNum){
IMENSE HERE- deleted
}
return v;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Log.i("FragmentList", "Item clicked: " + id);
}
}
LogCat:
01-14 21:42:13.969: E/dalvikvm-heap(17739): Creating VM heap of size start:2097152 max:536870912 base:0x4000c000
01-14 21:42:14.089: E/Tethering(11125): <!>com.android.server.connectivity.Tethering 278<!> active iface (usb0) reported as added, ignoring
01-14 21:42:14.509: E/dalvikvm-heap(17750): Creating VM heap of size start:2097152 max:536870912 base:0x4000c000
01-14 21:42:14.749: I/ActivityManager(11125): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.swipefragments/.MainActivity } from pid 17750
01-14 21:42:14.769: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Launcher.java:1809:onPause()onPause
01-14 21:42:14.769: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:528:updateWallpaperOffset()1 firstEmptyScreen: 6
01-14 21:42:14.769: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:529:updateWallpaperOffset()1 getChildAt(firstEmptyScreen).getRight() 2240
01-14 21:42:14.769: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:536:updateWallpaperOffset()2 scrollRange: 1920, firstEmptyScreen: 6
01-14 21:42:14.779: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:542:updateWallpaperOffset()2 mCurDesktopState: 0, firstEmptyScreen: 6
01-14 21:42:14.779: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:547:updateWallpaperOffset()3 getScrollX: 960, mScrollX: 960
01-14 21:42:14.779: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:548:updateWallpaperOffset()3 getChildAt(firstEmptyScreen).getLeft(): 1920
01-14 21:42:14.779: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:554:updateWallpaperOffset()4 xOffset: 0.5
01-14 21:42:14.859: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:528:updateWallpaperOffset()1 firstEmptyScreen: 6
01-14 21:42:14.929: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:529:updateWallpaperOffset()1 getChildAt(firstEmptyScreen).getRight() 2240
01-14 21:42:14.929: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:536:updateWallpaperOffset()2 scrollRange: 1920, firstEmptyScreen: 6
01-14 21:42:14.929: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:542:updateWallpaperOffset()2 mCurDesktopState: 0, firstEmptyScreen: 6
01-14 21:42:14.929: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:547:updateWallpaperOffset()3 getScrollX: 960, mScrollX: 960
01-14 21:42:14.939: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:548:updateWallpaperOffset()3 getChildAt(firstEmptyScreen).getLeft(): 1920
01-14 21:42:14.959: I/#LGIME(11205): <!>com.jungle.android.utils.Glog 35<!> ### onFinishInput
01-14 21:42:14.959: I/#LGIME(11205): <!>com.jungle.android.utils.Glog 35<!> #### onStartInput restarting : false / inputType : 0
01-14 21:42:14.959: I/Flex(11205): <!>com.lge.provider.Andy_Flex 186<!> getMccCode numeric 22610
01-14 21:42:14.969: I/Flex(11205): <!>com.lge.provider.Andy_Flex 218<!> getMncCode numeric 22610
01-14 21:42:14.969: I/#LGIME(11205): <!>com.jungle.android.utils.Glog 35<!> updateSIMInfo -> Old MCC : 226,Old MNC : 3 MCC = 226 MNC = 10
01-14 21:42:14.999: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:554:updateWallpaperOffset()4 xOffset: 0.5
01-14 21:42:15.139: I/ActivityManager(11125): <!>com.android.server.am.ActivityRecord 444<!> Displayed com.example.swipefragments/.MainActivity: +329ms
01-14 21:42:16.119: E/Tethering(11125): <!>com.android.server.connectivity.Tethering 278<!> active iface (usb0) reported as added, ignoring
01-14 21:42:18.759: D/StatusBarPolicy(11197): [BRIGHTHY] 0. mDataNetType: 8
01-14 21:42:18.759: D/StatusBarPolicy(11197): [BRIGHTHY] curNetwork=22610 curHPLMN=22610
01-14 21:42:18.759: D/StatusBarPolicy(11197): [BRIGHTHY] getNationalRoaming=false Roaming=false
01-14 21:42:20.109: E/Tethering(11125): <!>com.android.server.connectivity.Tethering 278<!> active iface (usb0) reported as added, ignoring
01-14 21:42:22.109: E/Tethering(11125): <!>com.android.server.connectivity.Tethering 278<!> active iface (usb0) reported as added, ignoring
01-14 21:42:24.099: E/Tethering(11125): <!>com.android.server.connectivity.Tethering 278<!> active iface (usb0) reported as added, ignoring
01-14 21:42:30.759: D/StatusBarPolicy(11197): [BRIGHTHY] 0. mDataNetType: 8
01-14 21:42:30.759: D/StatusBarPolicy(11197): [BRIGHTHY] curNetwork=22610 curHPLMN=22610
01-14 21:42:30.759: D/StatusBarPolicy(11197): [BRIGHTHY] getNationalRoaming=false Roaming=false
01-14 21:42:30.829: V/DATA(11214): <!>com.android.internal.telephony.MMDataConnectionTracker 1820<!> [DCT] intent received :android.intent.action.SCREEN_OFF
01-14 21:42:30.839: V/FASTDORMANCTY(11214): <!>com.android.internal.telephony.LgeFastDormancyHandler 987<!> [UNKNOWN] intent received :android.intent.action.SCREEN_OFF
01-14 21:42:35.799: D/[Andy_Lock](11125): <!>com.android.internal.policy.impl.Andy_LockScreen 1556<!> getCurrentStatus simStateREADY
01-14 21:42:35.869: I/#LGIME(11205): <!>com.jungle.android.utils.Glog 35<!> Action : android.intent.action.CLOSE_SYSTEM_DIALOGS
01-14 21:42:35.879: E/WindowManager(11125): <!>com.android.internal.policy.impl.PhoneWindowManager 2211<!> bwk rotationForOrientationLw case return
ありがとうございました。