小编use*_*435的帖子

带有搜索实现的CursorTreeAdapter

我申请了 我正在使用CursorTreeAdapter作为ExpandableListView.现在我想使用搜索框来显示已过滤的ExpandableListView项.像这样:http://i.imgur.com/8ua7Mkl.png

这是我到目前为止的代码:

MainActivity.java:

package com.example.cursortreeadaptersearch;

import java.util.HashMap;

import android.app.SearchManager;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.provider.ContactsContract;
import android.support.v4.app.LoaderManager;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.util.Log;
import android.widget.ExpandableListView;
import android.widget.SearchView;
import android.widget.SearchView.OnCloseListener;
import android.widget.SearchView.OnQueryTextListener;

import com.actionbarsherlock.app.SherlockFragmentActivity;

public class MainActivity extends SherlockFragmentActivity {

    private SearchView search;
    private MyListAdapter listAdapter;
    private ExpandableListView myList;

    private final String DEBUG_TAG = getClass().getSimpleName().toString();

    /**
     * The columns we are interested in from the database
     */
    static …
Run Code Online (Sandbox Code Playgroud)

java search android android-cursor simplecursortreeadapter

15
推荐指数
1
解决办法
4022
查看次数

android-spinnerwheel - 单个选项卡可绘制

我想在WheelHorizo​​ntalView(包含在库中android-spinnerwheel)中设置单独的选项卡宽度和高度.并将该选项卡设置为支持选定/按下状态的drawable.

这可以在ViewPagerIndicator(with vpiTabPageIndicatorStyle)中完成,但我不能使用这个库.(这就是我用它做的vpiTabPageIndicatorStyle:http://pastebin.com/wB4vGMyJ)

我试过的是改变selectionDivider这个drawable:

<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:drawable="@drawable/drawable_daychooser_item_pressed" />
    <item android:state_selected="true" android:drawable="@drawable/drawable_daychooser_item_selected" />
    <item android:drawable="@drawable/drawable_daychooser_item_default" />
</selector>
Run Code Online (Sandbox Code Playgroud)

但那不起作用.我已经调查了wheel__attrs.xml但是我找不到另一个格式为drawable(引用)的属性.

这就是现在的情况:

之前

这就是我想要的:

后

如果你想知道为什么我从这里切换ViewPagerIndicatorandroid-spinnerwheel这里:ViewPagerIndicator - 将TabPageIndicator设置为中心

我也在android-spinnerwheelGitHub页面上问过这个问题,但是经过4个月没有任何回复我决定在这里问一下.

android android-library android-spinner android-drawable

10
推荐指数
1
解决办法
784
查看次数

ViewPagerIndicator - 将TabPageIndicator设置为中心

我制作了一份时间表申请表 我正在使用ViewPagerIndicator作为片段.但现在我有一个问题,我想把TabPageIndicator放到中心.像这样: 例

我想设置单个标签的宽度和高度.并将该选项卡设置为支持选定/按下状态的drawable.

我还没有找到解决这些问题的方法.我尝试的东西onPageSelectedContextThemeWrapper,但不工作.(也许我没有正确使用它).

除了ViewPagerIndicator之外,这一切都有可能成为或者我应该寻找其他东西吗?(也欢迎没有ViewPagerIndicator的其他选项).

图片上的应用程序是Untis Mobile,可以在PlayStore上找到.我已经问过创作者他们是怎么做的,但是他们说应用程序不是开源的.(但我在源代码中发现他们使用TwoDScrollView来做,但我不确定)

编辑:

造型固定vpiTabPageIndicatorStyle.(在XDA开发人员的帮助下!)

当我添加20个项目时,它会保留在中间但仅从项目4到项目17,项目1,2,3,18,19,20不在中间.看到:

错误

我可以添加3个空项目(或空白区域)以确保第一个和最后一个项目位于中间吗?像这样的东西(来自Untis Mobile应用程序):

好

(我已经尝试过android:paddingLeft,vpiTabPageIndicatorStyle但这不起作用)

我知道这viewPager.setCurrentItem(total/2)会将TabPageIndicator设置在中间,但是它会保持在中间位置,我无法选择其他一天(我称之为onPageScrolled).所以我想滚动选中的一个需要在中间.这可能吗?

java android horizontalscrollview android-scrollview viewpagerindicator

9
推荐指数
1
解决办法
2086
查看次数

对齐2个文本,1个正常,1个相反

我做了一个 应用程序有一个按钮,其中总共有4个文本,我想对齐第一个2.一个位于底部文本的最左侧,另一个位于底部文本的右侧.

所以从这个:

之前

setText(item.title + " " + item.roomId + "\n" + item.teacher + " " + item.classes);

对此:

之后(这就是我想要的)

setText(declare here a spannable);

我想我应该一起工作Spannable,我已经尝试了一些事情Alignment.ALIGN_NORMALAlignment.ALIGN_OPPOSITE,但我认为是应该首先计算底部文本的长度,然后做了比对.(我在这里找到了一个很好的例子,但它在我的设置中没有用).

我希望有人能指出我的方向.

编辑:

我不能(我认为)使用RelativeLayout或是LinearLayout因为我在另一个类(ScheduleItemView.java)中扩展按钮的原因:

/**
 * Custom view that represents a {@link ScheduleItem} instance, including its
 * title and time span that it occupies. Usually organized automatically by
 * {@link ScheduleItemsLayout} to match up against a {@link TimeRulerView}
 * instance. …
Run Code Online (Sandbox Code Playgroud)

java android alignment spannablestring

9
推荐指数
1
解决办法
897
查看次数