我需要将子视图设置为ViewPager的中心,并且我还要向当前视图边显示下一个和上一个视图的某些部分(如1下的当前屏幕).但目前当前视图从ViewPager的左侧开始(如预期的屏幕低于2).我怎样才能做到这一点?
这是我的代码..
MyViewPagerAdapter
public class MyViewPagerAdapter extends PagerAdapter {
private Activity mActivity;
private int mPageCount;
public MyViewPagerAdapter(Activity activity,int pageCount) {
mActivity = activity;
mPageCount = pageCount;
}
@Override
public int getCount() {
return mPageCount;
}
@Override
public boolean isViewFromObject(View view, Object obj) {
return (view ==(View)obj);
}
@Override
public Object instantiateItem(ViewGroup container,final int position) {
ViewGroup viewGroup = (ViewGroup)mActivity.getLayoutInflater().inflate(
R.layout.item_view, null);
viewGroup.setBackgroundColor(randomColor());
TextView textView = (TextView)viewGroup.findViewById(R.id.textView1);
textView.setText("Page: "+(position+1));
Button button = (Button) viewGroup.findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View …Run Code Online (Sandbox Code Playgroud) 我遇到了一个问题,GooglePlayServices应用程序正在使用我的应用程序进程为他们的服务,并显示进程数为2.
我已附上相同的屏幕截图.我不知道为什么会这样.
与我的应用程序进程相比,它占用的内存更多.
有人可以帮我解决这个问题.
我想在Activity.onTouchEvent()方法中做一些B.logic .它适用于TextView其他不可点击的视图.然而,它并没有被称为点击Button.但我也需要这个.
这是代码.
public class MainActivity extends Activity {
private static final String TAG = MainActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Oh shit!! click performed... :(", Toast.LENGTH_LONG).show();
}
});
}
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.d(TAG, "ssssssssssssssssssssssss:touch");
return super.onTouchEvent(event);
}
public boolean dispatchTouchEvent(MotionEvent event) {
int eventaction=event.getAction();
switch(eventaction) {
case MotionEvent.ACTION_MOVE:
break;
default:
break;
}
return super.dispatchTouchEvent(event);
}
}
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题.

当我使用Facebook的Android SDK单点登录时,我得到一个完全无用的页面.
"You have already authorized app. Press "Okay" to continue.
Run Code Online (Sandbox Code Playgroud)
此页面会破坏用户体验.如何删除此屏幕?
提前致谢.
注意:如果FB应用程序安装在设备中,我们将不会看到此问题.仅当FB应用程序在设备中不可用时才会引发此问题.
我试过下面的代码.但是,它始终会产生160*160尺寸的图像.
try {
//call the standard crop action intent (the user device may not support it)
Intent cropIntent = new Intent("com.android.camera.action.CROP");
//indicate image type and Uri
cropIntent.setDataAndType(Uri.fromFile(pictureFile), "image/*");
//set crop properties
cropIntent.putExtra("crop", "true");
//indicate aspect of desired crop
cropIntent.putExtra("aspectX", 100);
cropIntent.putExtra("aspectY", 100);
cropIntent.putExtra("scale", true);
//indicate output X and Y
cropIntent.putExtra("outputX", 500);
cropIntent.putExtra("outputY", 500);
//retrieve data on return
cropIntent.putExtra("return-data", true);
//start the activity - we handle returning in onActivityResult
startActivityForResult(cropIntent, CROP_IMAGE);
} catch(ActivityNotFoundException anfe) {
//display an error message
String errorMessage …Run Code Online (Sandbox Code Playgroud)