小编Xav*_*ler的帖子

如何使用SearchView过滤RecyclerView

我正在尝试SearchView从支持库实现.我希望用户使用它SearchView来过滤一部List电影RecyclerView.

到目前为止我已经按照了几个教程添加SearchViewActionBar,但是我不确定从哪里开始.我看过几个例子,但是当你开始输入时,它们都没有显示结果.

这是我的MainActivity:

public class MainActivity extends ActionBarActivity {

    RecyclerView mRecyclerView;
    RecyclerView.LayoutManager mLayoutManager;
    RecyclerView.Adapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_view);

        mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
        mRecyclerView.setHasFixedSize(true);

        mLayoutManager = new LinearLayoutManager(this);
        mRecyclerView.setLayoutManager(mLayoutManager);

        mAdapter = new CardAdapter() {
            @Override
            public Filter getFilter() {
                return null;
            }
        };
        mRecyclerView.setAdapter(mAdapter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar …
Run Code Online (Sandbox Code Playgroud)

android searchview android-filterable android-recyclerview

299
推荐指数
5
解决办法
19万
查看次数

使用向上/向下滑动动画显示和隐藏视图

我有一个LinearLayout我希望显示或隐藏的内容Animation,只要我改变其可见性,就会向上或向下推动布局.

我在那里看到了一些样品,但它们都不适合我的需要.

我为动画创建了两个xml文件,但是当我更改a的可见性时,我不知道如何启动它们LinearLayout.

animation android android-animation

287
推荐指数
9
解决办法
33万
查看次数

Android在设置时添加简单的动画(view.Gone)

我设计了一个简单的布局.我已经完成了没有动画的设计,但现在我想在textview点击事件时添加动画,我不知道如何使用它.我的xml设计看起来好不好?任何建议,将不胜感激.

我的XML

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:longClickable="false"
    android:orientation="vertical"
    android:weightSum="16" >

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:orientation="vertical"
    android:background="#00DDA0"
    android:layout_weight="3" >
</LinearLayout>
 <TextView
        android:id="@+id/Information1"
        android:layout_width="match_parent"
        android:layout_height="1dp" 
        android:text="Child Information" 
        android:background="#0390BE"
        android:layout_weight="0.75"
        android:textColor="#FFFFFF"
        android:layout_gravity="center|fill_horizontal"/>

 <LinearLayout
     android:id="@+id/layout1"
     android:layout_width="fill_parent"
     android:layout_height="0dp"
     android:layout_weight="8.5"
     android:background="#BBBBBB"
     android:orientation="vertical" >

     <TextView
         android:id="@+id/textView1"
         android:layout_width="match_parent"
         android:layout_height="match_parent"        
         android:text="TextView" />
 </LinearLayout>

  <TextView
        android:id="@+id/Information2"
        android:layout_width="match_parent"
        android:layout_height="0dp" 
        android:text="Parent Information" 
        android:background="#0390BE"
        android:layout_weight="0.75"
        android:textColor="#FFFFFF"
        android:layout_gravity="center|fill_horizontal"/>
  <LinearLayout 
          android:id="@+id/layout2"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:orientation="vertical"
    android:background="#BBBBBB"
    android:layout_weight="8.5" >
     <TextView
         android:id="@+id/textView2"
         android:layout_width="match_parent"
         android:layout_height="match_parent"        
         android:text="TextView" />
      </LinearLayout>
   <TextView
        android:id="@+id/Information3"
        android:layout_width="match_parent"
        android:layout_height="0dp" 
        android:text="Siblings" 
        android:background="#0390BE"
        android:layout_weight="0.75"
        android:textColor="#FFFFFF"
        android:layout_gravity="center|fill_horizontal"/> …
Run Code Online (Sandbox Code Playgroud)

java android android-animation

204
推荐指数
8
解决办法
19万
查看次数

了解RecyclerView setHasFixedSize

我理解起来有些困难setHasFixedSize().我知道,当RecyclerView文档中的大小不变时,它用于优化.

这意味着什么?在大多数常见情况下,ListView几乎总是具有固定的大小.在什么情况下它不是固定的大小?这是否意味着它在屏幕上占据的实际房地产随着内容的增长而增长?

android android-5.0-lollipop android-recyclerview

120
推荐指数
5
解决办法
6万
查看次数

e.getMessage()和e.getLocalizedMessage()之间的区别

  • 我正在使用这两种方法来获取catch块在执行错误处理时抛出的消息
  • 他们两个都从错误处理中得到了消息,但这两者究竟有什么不同
  • 我从网上搜索了一下,从这里得到了这个答案

Java Exceptions从Throwable继承了它们的getMessage和getLocalizedMessage方法(参见相关链接).不同之处在于子类应覆盖getLocalizedMessage以提供特定于语言环境的消息.例如,您正在将来自美国英语公司/团队的代码调整为英国 - 英语组的成像.您可能希望创建自定义的Exception类,该类覆盖getLocalizedMessage以更正拼写和语法,以及将使用您的代码的用户和开发人员可能期望的内容.这也可以用于Exception消息的实际翻译.


问题 ::

  • 这是否意味着language specific实施?就像我使用e.getLocalizedMessage()我的应用程序一样English- 错误将被抛入English,如果我使用我的应用程序Spanish- 然后错误将被抛入Spanish

  • 需要一些明确的解释,我可以在何时何地使用这些方法

java android

73
推荐指数
3
解决办法
6万
查看次数


用于ListView的ScrollingViewBehavior

我有两个使用AppBarLayouta ToolbarTabLayout来自支持库22的活动.

两者的布局非常相似:A Toolbar在顶部,在它TabLayout下面,在它下面,ViewPager包含3 Fragment秒.

第一个活动Fragment有一个RecyclerView,第二个活动Fragment是使用一个ListView.

Toolbar来自https://github.com/chrisbanes/cheesesquare的可滚动示例在使用的第一个活动上工作正常RecyclerView,但是使用了ListView.

我试过创建了一个ListViewScrollBehavior扩展的自定义AppBarLayout.ScrollingViewBehavior,但到目前为止还没有运气.在TouchEvent滚动当s传递到自定义类只为横向滚动,而不是ListView(垂直).

任何方式使用CoordinatorLayoutListView

android android-listview android-support-library android-recyclerview

34
推荐指数
4
解决办法
2万
查看次数

android.util.AndroidRuntimeException:您无法组合滑动解雇和操作栏

我是android编程的新手并开始了一个示例hello world程序,但是遇到了以下错误:

07-05 13:52:20.830: W/dalvikvm(898): threadid=1: thread exiting with uncaught exception (group=0xb2ac4d70)
07-05 13:52:20.850: E/AndroidRuntime(898): FATAL EXCEPTION: main
07-05 13:52:20.850: E/AndroidRuntime(898): Process: com.example.helloandroid, PID: 898
07-05 13:52:20.850: E/AndroidRuntime(898): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloandroid/com.example.helloandroid.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-05 13:52:20.850: E/AndroidRuntime(898):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-05 13:52:20.850: E/AndroidRuntime(898):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-05 13:52:20.850: E/AndroidRuntime(898):  at android.app.ActivityThread.access$800(ActivityThread.java:138)
07-05 13:52:20.850: E/AndroidRuntime(898):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
07-05 13:52:20.850: E/AndroidRuntime(898):  at android.os.Handler.dispatchMessage(Handler.java:102)
07-05 13:52:20.850: E/AndroidRuntime(898):  at android.os.Looper.loop(Looper.java:136)
07-05 13:52:20.850: E/AndroidRuntime(898):  at android.app.ActivityThread.main(ActivityThread.java:5026)
07-05 …
Run Code Online (Sandbox Code Playgroud)

android runtime-error

31
推荐指数
4
解决办法
3万
查看次数

为什么C++不支持强类型省略号?

有人可以向我解释为什么C++,至少据我所知,没有实现一个强类型的省略号函数,这是有效的:

void foo(double ...) {
 // Do Something
}
Run Code Online (Sandbox Code Playgroud)

这意味着,简单地说:'用户可以将可变数量的术语传递给foo函数,但是,所有术语必须是双倍的'

c++ ellipsis variadic-functions

29
推荐指数
3
解决办法
7567
查看次数

类型动画师的预期资源[ResourceType]

我已将我的SDK更新到最新版本,但现在我收到了一个lint错误.

错误:animator类型的预期资源[ResourceType]

此行发生错误:

AnimatorInflater.loadAnimator(context, R.anim.right_slide_in)
Run Code Online (Sandbox Code Playgroud)

引用的资源/res/anim/right_slide_in.xml如下所示:

<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:valueTo="0"
    android:valueFrom="1.0"
    android:propertyName="xFraction"
    android:valueType="floatType"
    android:duration="450" />
Run Code Online (Sandbox Code Playgroud)

它以前总是奏效.有人可以解释为什么我会收到这个错误吗?

android android-animation android-lint

26
推荐指数
1
解决办法
2万
查看次数