我尝试从几天开始在底部创建一个固定描述的活动,上面的几张图片我没有错误,但屏幕上没有任何内容!
-Images必须加载服务器,必须用手指逐一刷卡
所以我创建了一个简单的LinearLayout activity_pearsonages_details.xml,其中包含两个TextView和一个像这样的ViewPager
<?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="vertical"
android:padding="@dimen/layout_details_padding"
tools:context="com.com.testapp.ui.PersonagesDetails">
<android.support.v4.view.ViewPager
android:id="@+id/vpid"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</android.support.v4.view.ViewPager>
<TextView
android:id="@+id/intro_details"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="30dp"
android:text=""
android:textColor="@color/gray_intro" />
<TextView
android:id="@+id/full_description_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text=""
android:textColor="@color/black" />
</LinearLayout>
然后滑动布局
<?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="vertical">
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/img_view_swipe"
android:layout_width="match_parent"
android:layout_height="200dip"
android:background="@color/black" />
</LinearLayout>
然后我创建了一个从PagerAdapter扩展的类
public class CustomSwipeAdapter extends PagerAdapter {
private ArrayList<String> imagesURLS;
private Context context;
private LayoutInflater inflater;
ImageLoader imageLoader = AppController.getInstance().getImageLoader();
public CustomSwipeAdapter(Context cnx) {
this.context = cnx;
}
@Override
public int getCount() {
return imagesURLS.size() - 1;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return (view == (LinearLayout) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
NetworkImageView thumbNail;
inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
View item_view = inflater.inflate(R.layout.swipe_layout, container, false);
if (imageLoader == null)
imageLoader = AppController.getInstance().getImageLoader();
thumbNail = (NetworkImageView) item_view.findViewById(R.id.img_view_swipe);
thumbNail.setImageUrl(imagesURLS.get(position), imageLoader);
container.addView(item_view);
//return super.instantiateItem(container, position);
return item_view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((LinearLayout) object);
}
public void setURLS(ArrayList l) {
for (int i = 0; i < l.size(); i++) {
Log.i("CCKURL", l.get(i).toString() + "---OK--");
}
this.imagesURLS = l;
}}
in the main activity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pearsonages_details);
viewPager = (ViewPager) findViewById(R.id.vpid);
adapter = new CustomSwipeAdapter(this);
adapter.setURLS(imageUrlList);
viewPager.setAdapter(adapter);
//customActionBar();
title = getIntent().getExtras().getString("title");
color = getIntent().getExtras().getString("color");
intro = getIntent().getExtras().getString("into");
full_description = getIntent().getExtras().getString("full_description");
Log.i("LOGFULL_DESC", full_description + "+++++");
actionbar = getSupportActionBar();
intoTxtV = (TextView) findViewById(R.id.intro_details);
descTxtV = (TextView) findViewById(R.id.full_description_detail);
intoTxtV.setText(intro);
descTxtV.setText(full_description);
imageUrlList = (ArrayList<String>) getIntent().getStringArrayListExtra("key");
customActionBar();}
最后这是我的凌空唱法课程
public class AppController extends Application {
public static final String TAG = AppController.class.getSimpleName();
private RequestQueue mRequestQueue;
private ImageLoader mImageLoader;
private static AppController mInstance;
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
}
public static synchronized AppController getInstance() {
return mInstance;
}
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}
return mRequestQueue;
}
public ImageLoader getImageLoader() {
getRequestQueue();
if (mImageLoader == null) {
mImageLoader = new ImageLoader(this.mRequestQueue,
new LruBitmapCache());
}
return this.mImageLoader;
}
public <T> void addToRequestQueue(Request<T> req, String tag) {
// set the default tag if tag is empty
req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
getRequestQueue().add(req);
}
public <T> void addToRequestQueue(Request<T> req) {
req.setTag(TAG);
getRequestQueue().add(req);
}
public void cancelPendingRequests(Object tag) {
if (mRequestQueue != null) {
mRequestQueue.cancelAll(tag);
}
}
没有崩溃,但我把它放到了我的logcat
13 12:08:36.587 8607-8607/com.com.testapp E/dalvikvm:: Could not find class 'android.os.PersistableBundle', referenced from method com.com.testapp.ui.PersonagesDetails.access$super
09-13 12:08:36.587 8607-8607/com.com.testapp W/dalvikvm: VFY: unable to resolve check-cast 238 (Landroid/os/PersistableBundle;) in Lcom/com/testapp/ui/PersonagesDetails;
09-13 12:08:36.587 8607-8607/com.com.testapp D/dalvikvm: VFY: replacing opcode 0x1f at 0x1380
09-13 12:08:36.587 8607-8607/com.com.testapp I/dalvikvm: Could not find method android.content.ContextWrapper.getObbDirs, referenced from method com.com.testapp.ui.PersonagesDetails.access$super
09-13 12:08:36.587 8607-8607/com.com.testapp W/dalvikvm: VFY: unable to resolve virtual method 548: Landroid/content/ContextWrapper;.getObbDirs ()[Ljava/io/File;
09-13 12:08:36.587 8607-8607/com.com.testapp D/dalvikvm: VFY: replacing opcode 0x6f at 0x13a7
09-13 12:08:36.587 8607-8607/com.com.testapp I/dalvikvm: Could not find method android.app.Activity.startPostponedEnterTransition, referenced from method com.com.testapp.ui.PersonagesDetails.access$super
09-13 12:08:36.587 8607-8607/com.com.testapp W/dalvikvm: VFY: unable to resolve virtual method 237: Landroid/app/Activity;.startPostponedEnterTransition ()V
09-13 12:08:36.587 8607-8607/com.com.testapp D/dalvikvm: VFY: replacing opcode 0x6f at 0x13ad
09-13 12:08:36.587 8607-8607/com.com.testapp I/dalvikvm: Could not find method android.content.ContextWrapper.getExternalCacheDirs, referenced from method com.com.testapp.ui.PersonagesDetails.access$super
09-13 12:08:36.587 8607-8607/com.com.testapp W/dalvikvm: VFY: unable to resolve virtual method 539: Landroid/content/ContextWrapper;.getExternalCacheDirs ()[Ljava/io/File;
09-13 12:08:36.587 8607-8607/com.com.testapp D/dalvikvm: VFY: replacing opcode 0x6f at 0x141f
09-13 12:08:36.587 8607-8607/com.com.testapp I/dalvikvm: Could not find method android.app.Activity.onEnterAnimationComplete, referenced from method com.com.testapp.ui.PersonagesDetails.access$super
09-13 12:08:36.587 8607-8607/com.com.testapp W/dalvikvm: VFY: unable to resolve virtual method 132: Landroid/app/Activity;.onEnterAnimationComplete ()V
09-13 12:08:36.587 8607-8607/com.com.testapp D/dalvikvm: VFY: replacing opcode 0x6f at 0x1462
09-13 12:08:36.615 8607-8607/com.com.testapp I/dalvikvm: DexOpt: illegal method access (call Landroid/support/v4/view/PagerAdapter;.setViewPagerObserver (Landroid/database/DataSetObserver;)V from Lcom/com/testapp/adapter/CustomSwipeAdapter;)
09-13 12:08:36.615 8607-8607/com.com.testapp I/dalvikvm: Could not find method android.support.v4.view.PagerAdapter.setViewPagerObserver, referenced from method com.com.testapp.adapter.CustomSwipeAdapter.access$super
09-13 12:08:36.615 8607-8607/com.com.testapp W/dalvikvm: VFY: unable to resolve virtual method 7416: Landroid/support/v4/view/PagerAdapter;.setViewPagerObserver (Landroid/database/DataSetObserver;)V
09-13 12:08:36.615 8607-8607/com.com.testapp D/dalvikvm: VFY: replacing opcode 0x6f at 0x00d8
我不知道我的错误在哪里 欢迎任何想法谢谢