相关疑难解决方法(0)

如何在ListView中正确使用TextSwitcher?

TextSwitcher的每个记录ListView应显示第一个值(text1),然后显示另一个值(text2),然后再显示第一个值,依此类推.只有当text2不为空时才会发生.否则,应始终显示text1(不进行任何更改和动画).

我创建了Runnable(),它改变了布尔变量(time2)然后调用items.notifyDataSetChanged().它按预期工作,结果setViewValue()ListView被称为.

这是代码:

items.setViewBinder(new SimpleCursorAdapter.ViewBinder() {

    @Override
    public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
      int viewId = view.getId();
      switch(viewId) {
      case R.id.timetext:
          TextSwitcher itemTime = (TextSwitcher) view;
          if (itemTime.getChildCount() != 2) {
              itemTime.removeAllViews();
              itemTime.setFactory(new ViewSwitcher.ViewFactory() {
                  @Override
                  public View makeView() {
                      TextView t = new TextView(MyActivity.this);
                      t.setTextSize(18);
                      t.setTypeface(null, Typeface.BOLD);
                      t.setTextColor(Color.WHITE);
                      return t;
                    }
                  });
              itemTime.setAnimateFirstView(true);
              itemTime.setInAnimation(AnimationUtils.loadAnimation(MyActivity.this, …
Run Code Online (Sandbox Code Playgroud)

sqlite android android-listview

8
推荐指数
1
解决办法
1849
查看次数

标签 统计

android ×1

android-listview ×1

sqlite ×1