我Navigation Drawer在我的应用程序中使用.
当用户点击抽屉中的任何菜单项时,它会打开一个新的Activity (不是片段).
现在,我正在使用slide_right_in/slide_left_out animation活动之间的过渡.
代码有效,但这些动画与导航抽屉的关闭动画冲突,因为即使在抽屉完全关闭之前,当前活动开始向左滑动,下一个活动开始从右侧滑入.
那么,只有在抽屉完全关闭后才能启动动画吗?
谢谢
在我的活动中,我正在维护一个SuperActivity,我正在设置主题.
public class SuperActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.MyTheme);
}
}
Run Code Online (Sandbox Code Playgroud)
的themes.xml
<!-- ImageBackround -->
<style name="Theme.MyTheme" parent="ThemeLight">
<item name="myBgColor">@color/translucent_black</item>
</style>
Run Code Online (Sandbox Code Playgroud)
现在我想在我的一个孩子活动中获取这种颜色.
正如在这个可能的答案中所提到的,我写道:
int[] attrs = new int[] { R.attr.myBgColor /* index 0 */};
TypedArray ta = ChildActivity.this.obtainStyledAttributes(attrs);
int color = ta.getColor(0, android.R.color.background_light);
String c = getString(color);
ta.recycle();
Run Code Online (Sandbox Code Playgroud)
但每次我得到的默认值为android.R.color.background_light&而不是R.attr.myBgColor.
哪里我做错了.我是否传递了错误的背景ChildActivity.this?
我已经创建了一个我想在我的应用程序中使用的自定义Exception类:
public class MyException extends Exception {
private static final long serialVersionUID = -2151515147355511072L;
private String message = null;
public MyException() {
super();
}
public MyException(String message) {
super(message);
this.message = message;
}
public MyException(Throwable cause) {
super(cause);
}
@Override
public String toString() {
return message;
}
@Override
public String getMessage() {
return message;
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用这个类时,如下所示,它会产生编译时错误.
try {
System.out.println("this");
} catch (MyException e) {
// TODO: handle exception
}
Run Code Online (Sandbox Code Playgroud)
编译时间错误:
Unreachable catch block for MyException . This exception is …Run Code Online (Sandbox Code Playgroud)