我正在创建一个目标为2.2的android应用程序。我仍然想使用android.support-v4.jar中提供的ViewPager。我希望在按钮点击时禁用ViewPager的滑动。我已经使用了以下代码来禁用,但它不起作用。
public class ServiesDeail extends FragmentActivity{
ServiesTitleFragmentAdapter mAdapter;
ViewPager mPager;
int position = 0 ;
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mastermenu);
LinearLayout lnrparent = (LinearLayout) findViewById(R.id.LL_001);
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.menu_deatil, null);
lnrparent.addView(view);
mAdapter = new ServiesTitleFragmentAdapter(getSupportFragmentManager());
mPager = (ViewPager) findViewById(R.id.pagerone);
mPager.setAdapter(mAdapter);
TitlePageIndicator indicator = (TitlePageIndicator) findViewById(R.id.indicatorone);
indicator.setViewPager(mPager,position);
Menu_Button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mPager.setClickable(false);
}
});
}
}
如果你有任何想法,请回复我。我在等待你的回复。