我正在尝试使用自定义动画来处理我的片段.
我已经按照在线教程,但我得到了以下错误:
java.lang.RuntimeException:未知的动画师名称:translate
动画的XML如下:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="100%"
android:toXDelta="0"
android:duration="300" />
</set>
Run Code Online (Sandbox Code Playgroud)
Java文件如下所示:
public void goCategory(View v) {
FragmentTransaction ft = fm.beginTransaction();
ft.setCustomAnimations(R.animator.anim_in_left, R.animator.anim_out_left);
ft.show(fragment);
ft.commit();
}
Run Code Online (Sandbox Code Playgroud)
我无法理解其他线程中的解决方案.如果有人能为我愚蠢,我真的很感激.
我在viewpager中有三个片段.
其中两个片段有自己的onCreateOptionsMenu方法版本:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
// Set up 1 action button
inflater.inflate(R.menu.home_snapshot_add, menu);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
// Set up 2 action buttons
inflater.inflate(R.menu.home_snapshot_send, menu);
}
Run Code Online (Sandbox Code Playgroud)
home活动有一个基本的onCreateOptionsMenu方法:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return false;
}
Run Code Online (Sandbox Code Playgroud)
在onCreate方法中,每个片段都调用该方法:
setHasOptionsMenu(true);
Run Code Online (Sandbox Code Playgroud)
每个菜单项都有标签:
android:showAsAction="always"
Run Code Online (Sandbox Code Playgroud)
好像我打开Activity一样,所有三个按钮都出现了.然而,当我滚动它们时,错误的那些神奇地消失了.感觉就像活动在Activity创建时调用每个Fragment的选项菜单,然后在我向左和向右滑动时适当地更改菜单.我检查了菜单,但不确定是什么问题.您认为我需要检查的任何事情?我有点想法了.
谢谢!
android android-fragments android-optionsmenu android-actionbar
我在build.gradle中做了一些事情来删除androidTest.java包的绿色突出显示.
我不知道怎么回来.
IntelliJ在上下文菜单中有一个"Mark directory as test sources root"选项,但我在Android Studio中找不到等效项.
有没有办法定义这个文件夹,所以我可以开始测试?(如果它意味着什么,测试java文件都有一个"J"的图标,周围有一个红色圆圈)
我在用Android Studio 1.1 RC 1.
我已经将一个外部库导入Gradle:
compile 'com.rengwuxian.materialedittext:library:1.8.3'
Run Code Online (Sandbox Code Playgroud)
我添加了命名空间标记:
xmlns:app="http://schemas.android.com/apk/res-auto"
Run Code Online (Sandbox Code Playgroud)
进入父母如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/primary_light"
android:orientation="vertical"
android:padding="20dp"
tools:context="net.xxx.xxx.ui.activities.Activity"/>
Run Code Online (Sandbox Code Playgroud)
我获得了库中自定义视图的代码完成,即:
<com.rengwuxian.materialedittext.MaterialAutoCompleteTextView />
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试为此视图的属性执行代码完成时,没有任何内容出现.我必须手动输入所有这些.
<com.rengwuxian.materialedittext.MaterialAutoCompleteTextView
android:id="@+id/autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:completionThreshold="3"
android:hint="Enter name"
android:imeOptions="actionDone"
app:floatingLabel="normal"
app:floatingLabelText="Find xxx"/>
Run Code Online (Sandbox Code Playgroud)
我缺少一个设置或导入吗?
有用的信息: 可以在此处找到库中的属性文件. https://github.com/rengwuxian/MaterialEditText/blob/master/library/src/main/res/values/attrs.xml
我遇到了TextView的elegantTextHeight属性,但是当我玩它时没有看到任何变化.
它有什么作用?我该如何使用它?
我刚开始使用greenDAO.如何添加枚举属性?
我的想法:使用实体的addIndex属性.
private static void main() {
// TODO Auto-generated method stub
static Schema blah;
Entity unicorn = blah.addEntity("Weather");
unicorn.addIdProperty();
unicorn.addIntProperty("currentAirTemp");
unicorn.addIndex("shirtSize");
}
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?
目标:我希望引用来自套装的shirtSize:{XS,S,M,L,XL,XXL}
目标: 我正在寻找一种方法将功能附加到按钮的onClickListener上.
插图
Button trigger = new Button(getActivity());
trigger.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
method1();
}
});
Button runMethod2Button = new Button(getActivity());
runMethod2Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
method1();
method2();
}
});
Button runMethod3Button = new Button(getActivity());
runMethod3Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
method1();
method3();
method4();
}
});
Run Code Online (Sandbox Code Playgroud)
我知道我们可以通过调用继承来做到这一点
@Override
public void method(){
super.method();
// Do appended stuff
}
Run Code Online (Sandbox Code Playgroud)
或者我们可以内联
new Object(){
@Override
public void method(){
super();
// Do appended stuff …Run Code Online (Sandbox Code Playgroud) 我创建了一个活动,让用户使用PlacePicker选择一个地方.但是,此处没有搜索功能.
我可以设置任何标志告诉PlacePicker Intent包含搜索栏吗?