我有四个活动,比如A,B,C和D.我的情况是A将通过startActivityForResult启动活动B.
startActivityForResult(new Intent(this,B.class),ONE);
Run Code Online (Sandbox Code Playgroud)
在其他情况下,我将B与其他情况.喜欢
startActivityForResult(new Intent(this,B.class),TWO);
Run Code Online (Sandbox Code Playgroud)
在B中,我需要根据requestCode调用C或D. 即如果ONE需要启动C else D.
所以我需要知道如何检查子Activity中的requestCode(这里是B).
换句话说,我想获得活动B开始的请求代码.
android android-intent android-activity startactivityforresult
我在Honeycomb开发了一个应用程序,我正在使用片段.
这是我的应用程序
我的问题是什么
当用户旋转设备时,重新创建活动并使F1成为片段对象,即使在旋转之前它不是
我使用但它对我不起作用
我已经在我的函数中添加了代码片段,就像这样
What is the way to retain the fragment object while rotating?setRetainInstance(true);onCreate
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
Fragment homeFragment = new Home();
fragmentTransaction.add(R.id.mainFragement, homeFragment);
fragmentTransaction.commit();
}
Run Code Online (Sandbox Code Playgroud) android screen-rotation android-fragments android-3.0-honeycomb
我开始这样的活动
Intent mainIntent = new Intent(v.getContext(), Second.class);
startActivity(mainIntent);
overridePendingTransition(android.R.anim.slide_out_right,
android.R.anim.slide_in_left);
Run Code Online (Sandbox Code Playgroud)
我为动画设置了overridePendingTrasition.
你可以看到我已经将oposite设置为正常的 android startactivity动画.所以现在这两个动画相互折叠了.
我想在启动活动时阻止默认动画(左 - >右)
谢谢
我有一个activity在其中有一个async task会做一些下载的东西.在下载时它会显示al oading dialog.
我的问题是,当我这样做时,它对我来说很好one orentiaon.但是当我rotate在下载时,它显示window leaked并将
dialog.cancel 在我的帖子中执行崩溃.
从我对它的研究中我理解它是因为change in the context设备何时出现rotated.
也就是说,当device是rotated该activity会recreated所以context会changed.
但我已经创建了与旧的对话框wasn't the current context.因此,当我取消它时显示错误
这是什么解决方案,任何想法frnds.
我使用honeycomb,我试过,fragment但没有得到一个很好的样本.我现在主要尝试这个,
如果有人可以给我一些链接,那将是伟大的
使用蜂窝模拟器时显示以下错误并变得非常慢.
02-11 02:58:50.949: ERROR/ActivityManager(365): ANR in com.android.launcher (com.android.launcher/com.android.launcher2.Launcher)
02-11 02:58:50.949: ERROR/ActivityManager(365): Reason: keyDispatchingTimedOut
02-11 02:58:50.949: ERROR/ActivityManager(365): Load: 2.57 / 1.18 / 0.89
02-11 02:58:50.949: ERROR/ActivityManager(365): CPU usage from 3042ms to -7585ms ago:
02-11 02:58:50.949: ERROR/ActivityManager(365): 74% 365/system_server: 53% user + 21% kernel / faults: 335 minor
02-11 02:58:50.949: ERROR/ActivityManager(365): 9% 780/zygote: 3.8% user + 5.1% kernel / faults: 915 minor
02-11 02:58:50.949: ERROR/ActivityManager(365): 8.2% 684/com.android.launcher: 6% user + 2.1% kernel / faults: 51 minor
02-11 02:58:50.949: ERROR/ActivityManager(365): 0% 432/zygote: 0% …Run Code Online (Sandbox Code Playgroud)
我想,以取代其他其他通过代码视图
例如,我需要改变imageview,以progressBar通过代码.
public void changeToProgressBar(ImageView imageview,Context context){
ProgressBar one = new ProgressBar(context);
one.setLayoutParams(imageview.getLayoutParams());
imageview.setVisibility(View.GONE);
one.setVisibility(View.VISIBLE);
//NOW I NEED TO PLACE 'one' EXACTLY THE PLACE WHERE 'imageview' WAS THERE
}
Run Code Online (Sandbox Code Playgroud)
我需要使用这么多地方.我知道通过发送父母来设置viewgroup.
无论如何viewgroup要从父母那里得到imageview
感谢
我使用以下代码在布局中添加视图
LinearLayout linearLayout_row1_recent_released = (LinearLayout)findViewById(R.id.linearLayout);
View myview = findViewById(R.layout.row);
Button button = myview.findViewById(R.id.mybutton);
linearLayout_row1_recent_released.removeAllViews();
linearLayout_row1_recent_released.addView(myview,LinearLayout.LayoutParams.FILL_PARENT);
Run Code Online (Sandbox Code Playgroud)
使用row.xml我试图获得一个视图.我得到的是一个致命的例外.
02-11 02:59:04.278: ERROR/AndroidRuntime(780): FATAL EXCEPTION: main
02-11 02:59:04.278: ERROR/AndroidRuntime(780): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aaaaa.ap/com.aaaaaa.ap.AppPlaceMain}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aaaaaa.ap/com.aaaaaa.ap.Store}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aaa.ap/com.aaaaaa.ap.catalog.Home}: java.lang.NullPointerException
02-11 02:59:04.278: ERROR/AndroidRuntime(780): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1701)
02-11 02:59:04.278: ERROR/AndroidRuntime(780): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1717)
02-11 02:59:04.278: ERROR/AndroidRuntime(780): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
02-11 02:59:04.278: ERROR/AndroidRuntime(780): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:984)
02-11 02:59:04.278: ERROR/AndroidRuntime(780): at android.os.Handler.dispatchMessage(Handler.java:99)
02-11 02:59:04.278: ERROR/AndroidRuntime(780): at android.os.Looper.loop(Looper.java:126)
02-11 02:59:04.278: ERROR/AndroidRuntime(780): at android.app.ActivityThread.main(ActivityThread.java:3900)
02-11 …Run Code Online (Sandbox Code Playgroud) 我不知道这是正确的问题.因为我需要了解NFC的概念.来自Android 2.3平台参考.我用Google搜索了它.但我没有得到正确的概念.任何人都可以为我提供良好的链接和教程.以及如何在android中实现它.
我有以下情况
TabActivity>group activiyt>(A->B->C)
Run Code Online (Sandbox Code Playgroud)
这里A,B和C是活动.我加载这样的
setContentView(this,getLocalActivityManager().startActivity("zero",intent.addFlags(Intent.FLG_ACTIVITY_CLEAR_TOP)) .getDecorView());
Run Code Online (Sandbox Code Playgroud)
我需要的是当我将一个活动改为另一个活动时设置动画(从左/右滑动)?
目前我使用以下动画,后setContentView到新视图
public static Animation inFromRightAnimation() {
Animation inFromRight = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
inFromRight.setDuration(ANIMATIION_DURATION);
inFromRight.setInterpolator(new AccelerateInterpolator());
return inFromRight;
}
Run Code Online (Sandbox Code Playgroud)
但它只对新视图进行动画制作.
我需要当前的左移同时从右移动新的移动
有没有办法设置setInAnimation和setOutAnimationstartActivity像视图翻板?
谢谢