0
回答
滑动页面上的功能实现,出错了大哥们
滴滴云服务器,限时包月0.9元,为开发者而生>>>   

package com.yunk;


import java.util.ArrayList;
import java.util.List;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;


public class PersonJobFair extends Activity {
private ListView listView;
private ViewPager myViewPager;


private MyPagerAdapter myAdapter;


private LayoutInflater mInflater;
private List<View> mListViews;
private View layout1 = null;
private View layout2 = null;
private View layout3 = null;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.jobfair_father);


myAdapter = new MyPagerAdapter();
myViewPager = (ViewPager) findViewById(R.id.viewpagerLayout);
myViewPager.setAdapter(myAdapter);


mListViews = new ArrayList<View>();
/*将要分页显示的View装入数组中*/
mInflater = getLayoutInflater();
layout1 = mInflater.inflate(R.layout.jobfair_end, null);
layout2 = mInflater.inflate(R.layout.jobfair_now, null);
layout3 = mInflater.inflate(R.layout.jobfair_coming, null);


mListViews.add(layout1);
mListViews.add(layout2);
mListViews.add(layout3);


// 初始化当前显示的view
myViewPager.setCurrentItem(1);


// //初始化第二个view的信息
// EditText v2EditText = (EditText)layout2.findViewById(R.id.editText1);
// v2EditText.setText("动态设置第二个view的值");


myViewPager.setOnPageChangeListener(new OnPageChangeListener() {


@Override
public void onPageSelected(int arg0) {
Log.d("k", "onPageSelected - " + arg0);
}


@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
Log.d("k", "onPageScrolled - " + arg0);
}


@Override
public void onPageScrollStateChanged(int arg0) {
Log.d("k", "onPageScrollStateChanged - " + arg0);



}
});


}
private class MyPagerAdapter extends PagerAdapter {


public void destroyItem(View arg0, int arg1, Object arg2) {
Log.d("k", "destroyItem");
((ViewPager) arg0).removeView(mListViews.get(arg1));
}


@Override
public void finishUpdate(View arg0) {
Log.d("k", "finishUpdate");
}


@Override
public int getCount() {
Log.d("k", "getCount");
return 3;
// return mListViews.size();
}


@Override
public Object instantiateItem(View arg0, int arg1) {
if (arg1 < 3) {

((ViewPager) arg0).addView(mListViews.get(arg1%3), 0);
}
if (arg1 == 0) {
listView = (ListView) findViewById(R.id.list);
Button bn1 = (Button) findViewById(R.id.back);
bn1.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
Intent mainIntent = new Intent(PersonJobFair.this, Main.class);
startActivity(mainIntent);
// TODO Auto-generated method stub

}
});

String[] items = new String[] {"我的基本信息","我的简历","我的收藏","我的申请记录"};

〈!--这是出问题的地方--〉
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this,
R.layout.my_item, R.id.fav_title, items);


listView.setAdapter(adapter1);


listView.setOnItemClickListener(new OnItemClickListener() {


public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
switch (arg2) {
case 0:
Intent intent = new Intent(PersonJobFair.this,
Main.class);
startActivity(intent);
break;

default:
break;
}


}


});


}
return mListViews.get(arg1 % 3); 


}


@Override
public boolean isViewFromObject(View arg0, Object arg1) {
Log.d("k", "isViewFromObject");
return arg0 == (arg1);
}


@Override
public void restoreState(Parcelable arg0, ClassLoader arg1) {
Log.d("k", "restoreState");
}


@Override
public Parcelable saveState() {
Log.d("k", "saveState");
return null;
}


@Override
public void startUpdate(View arg0) {
Log.d("k", "startUpdate");
}


}


}



这是问题提示

Multiple markers at this line

- The constructor ArrayAdapter<String>(PersonJobFair. MyPagerAdapter, int, int, String[]) is 
undefined
- Line breakpoint:PersonJobFair$MyPagerAdapter [line: 123] - instantiateItem(View, int)
<无标签>
举报
光旭
发帖于4年前 0回/114阅
顶部