2015-04-25 31 views
1

嘿傢伙我試圖刷我的活動之間使用PagerAdapter但我得到錯誤這裏是我的代碼,我有點新的Android開發,所以我無法理解我發現的問題互聯網上的解決方案。任何人都可以告訴我如何完全修復它?任何幫助將不勝感激,謝謝!這裏是我的代碼:無法安裝類型PagerAdapter?怎麼了?

PagerAdapter.java: -

package com.example.prototype; 

import java.util.List; 

import android.support.v4.app.Fragment; 
import android.support.v4.app.FragmentManager; 
import android.support.v4.app.FragmentPagerAdapter; 

public class PagerAdapter extends FragmentPagerAdapter { 

    private List<Fragment> fragments; 

    public PagerAdapter(FragmentManager fm, List<Fragment> fragments) { 
     super(fm); 
     this.fragments = fragments; 

    } 

    @Override 
    public Fragment getItem(int position) { 
     return this.fragments.get(position); 
    } 

    @Override 
    public int getCount() { 
     return this.fragments.size(); 
    } 
} 

ViewPagerFragmentActivity: -

package com.example.prototype; 

import java.util.List; 
import java.util.Vector; 

import android.os.Bundle; 
import android.support.v4.app.Fragment; 
import android.support.v4.app.FragmentActivity; 
import android.support.v4.view.PagerAdapter; 
import android.support.v4.view.ViewPager; 

import com.example.prototype.R; 
import com.example.prototype.Games; 
import com.example.prototype.Movies; 
import com.example.prototype.Songs; 

public class ViewPagerFragmentActivity extends FragmentActivity { 

    private PagerAdapter mPagerAdapter; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     super.setContentView(R.layout.viewpager_layout); 

     this.initialisePaging(); 
    } 

    private void initialisePaging() { 

     List<Fragment> fragments = new Vector<Fragment>(); 
     fragments.add(Fragment.instantiate(this, Games.class.getName())); 
     fragments.add(Fragment.instantiate(this, Movies.class.getName())); 
     fragments.add(Fragment.instantiate(this, Songs.class.getName())); 

     this.mPagerAdapter = new PagerAdapter(super.getSupportFragmentManager(), fragments);  //Error at this line!!! 

     ViewPager pager = (ViewPager) super.findViewById(R.id.viewpager); 
     pager.setAdapter(this.mPagerAdapter); 
    } 
} 

全logcat的: -

04-25 14:08:12.082: E/vinput-seamless(108): found PS2 device 
04-25 14:08:12.082: E/vinput-seamless(108): found seamless mouse device 
04-25 14:08:17.726: E/setdpi(286): Setting DPI to 240 
04-25 14:08:17.858: E/SurfaceFlinger(116): setOrientation with orientation=0 
04-25 14:08:17.858: E/SurfaceFlinger(116): setOrientation orientation=0 
04-25 14:08:17.858: E/FramebufferNativeWindow(116): setOrientation with fbDev=0xb85a1af0 fbDev->setOrientation=0xb6003f20 orientation=0 
04-25 14:08:18.230: E/local_camera(112): We have a problem with the player connection 22 (Invalid argument) 
04-25 14:08:21.930: E/PhonePolicy(117): Could not preload class for phone policy: com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback 
04-25 14:08:23.410: E/Genymotion(301): usbOnlinePath not found 
04-25 14:08:23.410: E/Genymotion(301): batteryStatusPath not found 
04-25 14:08:23.410: E/Genymotion(301): batteryHealthPath not found 
04-25 14:08:23.410: E/Genymotion(301): batteryPresentPath not found 
04-25 14:08:23.410: E/Genymotion(301): batteryCapacityPath and batteryEnergyPaths not found 
04-25 14:08:23.410: E/Genymotion(301): batteryVoltagePath not found 
04-25 14:08:23.410: E/Genymotion(301): batteryTemperaturePath not found 
04-25 14:08:23.410: E/Genymotion(301): batteryTechnologyPath not found 
04-25 14:08:25.174: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:08:25.182: E/libsuspend(301): Error opening /sys/power/autosleep: No such file or directory 
04-25 14:08:25.182: E/libsuspend(301): Error opening /sys/power/wakeup_count: Permission denied 
04-25 14:08:25.182: E/libsuspend(301): failed to initialize autosuspend 
04-25 14:08:25.282: E/WVMExtractor(119): Failed to open libwvm.so 
04-25 14:08:25.318: E/WVMExtractor(119): Failed to open libwvm.so 
04-25 14:08:25.326: E/EventHub(301): could not get driver version for /dev/input/mouse3, Not a typewriter 
04-25 14:08:25.350: E/EventHub(301): could not get driver version for /dev/input/mouse2, Not a typewriter 
04-25 14:08:25.366: E/EventHub(301): could not get driver version for /dev/input/mouse1, Not a typewriter 
04-25 14:08:25.406: E/EventHub(301): could not get driver version for /dev/input/mouse0, Not a typewriter 
04-25 14:08:25.442: E/EventHub(301): could not get driver version for /dev/input/mice, Not a typewriter 
04-25 14:08:25.458: E/ConnectivityService(301): Ignoring protectedNetwork 10 
04-25 14:08:25.458: E/ConnectivityService(301): Ignoring protectedNetwork 11 
04-25 14:08:25.458: E/ConnectivityService(301): Ignoring protectedNetwork 12 
04-25 14:08:25.466: E/WifiStateMachine(301): Failed to reload STA firmware java.lang.IllegalStateException: command '2 softap fwreload eth1 STA' failed with '400 2 Softap operation failed (Success)' 
04-25 14:08:25.570: E/WifiConfigStore(301): Error parsing configurationjava.io.FileNotFoundException: /data/misc/wifi/ipconfig.txt: open failed: ENOENT (No such file or directory) 
04-25 14:08:25.574: E/WifiStateMachine(301): Failed to set frequency band 0 
04-25 14:08:26.402: E/GpsLocationProvider(301): no AGPS interface in agps_data_conn_open 
04-25 14:08:26.454: E/ActivityThread(423): Failed to find provider info for com.android.inputmethod.latin.dictionarypack 
04-25 14:08:26.458: E/BinaryDictionaryGetter(423): Could not find a dictionary pack 
04-25 14:08:27.922: E/WVMExtractor(119): Failed to open libwvm.so 
04-25 14:08:28.074: E/WVMExtractor(119): Failed to open libwvm.so 
04-25 14:08:28.270: E/WVMExtractor(119): Failed to open libwvm.so 
04-25 14:08:28.314: E/WVMExtractor(119): Failed to open libwvm.so 
04-25 14:08:28.334: E/WVMExtractor(119): Failed to open libwvm.so 
04-25 14:08:30.174: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:08:51.417: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:08:56.417: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:09:01.418: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:09:06.417: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:09:11.417: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:09:16.418: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:09:21.417: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:09:26.418: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:09:31.421: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:09:36.421: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:09:41.421: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:09:46.429: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:09:51.430: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:09:56.433: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:10:01.433: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:10:06.434: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:10:11.434: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:10:16.433: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:10:21.433: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:10:26.437: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:10:31.437: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:10:36.437: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:10:41.437: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:10:46.438: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:10:51.437: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:10:56.437: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:11:01.441: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:11:06.441: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:11:11.441: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:11:16.441: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:11:21.441: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:11:26.441: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:11:31.442: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:11:36.445: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:11:41.445: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:11:46.445: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:11:51.445: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:11:56.446: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:12:01.445: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:12:06.445: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:12:11.445: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:12:16.445: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:12:21.445: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:12:26.449: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:12:31.449: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:12:36.449: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:12:41.449: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:12:46.449: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:12:51.450: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:12:56.449: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:13:01.449: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:13:06.453: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:13:11.453: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
04-25 14:13:16.453: E/Genymotion(301): Could not open '/sys/class/power_supply/genymotion_fake_path/present' 
+0

顯示堆棧跟蹤 –

+0

ViewPagerFragmentActivity

變化在哪裏可以找到它? –

+0

LogCat - >紅線 –

回答

3

你從框架進口PagerAdapter代替你的sublcass。在從

import android.support.v4.view.PagerAdapter; 

import com.example.prototype.PagerAdapter; 
+1

它爲我工作!噸感謝!真的很感謝你的幫助! –

相關問題