小编Ans*_*agi的帖子

Android ViewPager和TabLayout运行速度不快

有嵌套片段TabLayoutViewPager.每个片段里面都有listview,所以他们可以一起调用,现在我遇到了app处理速度慢的问题.我尝试过一些像凌空图书馆这样的解决方案,但它对我不起作用.更多我发布我的代码所以请指导我做到最好.

MainTabFragment.java

public class MainTabFragment extends Fragment {

public static int position_child_tab = 0, three_childs_tab_position = 0;
static int count = -1;
int position_tab = 0;
Bundle args;
MyTabLayout myTabLayout;

public MainTabFragment() {
    // Required empty public constructor
}

/**
 * Use this factory method to create a new instance of
 * this fragment using the provided parameters.
 *
 * @param param1 Parameter 1.
 * @param param2 Parameter 2.
 * @return A new instance of fragment …
Run Code Online (Sandbox Code Playgroud)

performance android android-fragments android-viewpager android-tablayout

23
推荐指数
2
解决办法
5854
查看次数

SearchView不会在TabLayout的每个子标签中进行过滤

在这里,我有一个toolbarActivity其中包含SearchView.而且该活动有多个片段.其中一个主要碎片本身内部还有10个碎片.所有10个片段都在列表视图中显示数据.现在,我试图通过筛选片段的所有列表SearchViewMainActivity.但它从不过滤每个片段的列表.现在我告诉你我是如何实现它的.

MainActivity.java

public class MainActivity extends AppCompatActivity {
 @Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    changeSearchViewTextColor(searchView);
    return true;
}
}
Run Code Online (Sandbox Code Playgroud)

Fragment.java

public class CurrencyFragment2 extends android.support.v4.app.Fragment implements SearchView.OnQueryTextListener {

    @Override
public void setMenuVisibility(boolean menuVisible) {
    super.setMenuVisibility(menuVisible);
    if (menuVisible && getActivity() != null) {
        SharedPreferences pref = getActivity().getPreferences(0);
        int id = pref.getInt("viewpager_id", 0);
        if (id == 2)
            setHasOptionsMenu(true); …
Run Code Online (Sandbox Code Playgroud)

java android filter android-fragments searchview

22
推荐指数
1
解决办法
5001
查看次数

在嵌套片段中运行多个AsyncTasks时挂起线程,这会使应用程序变慢

在这里,我在嵌套的Fragments中调用Web服务,它具有TabLayoutViewPager使用AsyncTask.我尝试AsyncTasks过将它们全部称为onResume各自的方法Fragment:

new FetchAllData(getActivity()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
Run Code Online (Sandbox Code Playgroud)

new FetchAllData(getActivity()).execute();
Run Code Online (Sandbox Code Playgroud)

一切都很好,但我遇到很多问题:

  • 应用程序停止工作,没有任何对话框,但它显示suspending all threads在logcat中.

  • 当我们从图像中显示的另一个活动中获取此片段(具有嵌套的tablayouts和viewpagers)时,除了工具栏之外,所有内容都会变为空白3到5秒.突然之间,他们带来了完整的数据.

  • 当我们从同一活动的另一个片段调用这个片段时,它会在那里冻结,这些片段会在那里突然打开.

我希望你能解决我的所有问题,如果没有请通知我.

Stacktrace是:

1-29 12:10:49.580 10853-10863/com.cws.advisorymandi W/art: Suspending all threads took: 10.409ms
 01-29 12:10:49.707 10853-10853/com.cws.advisorymandi D/cr_Ime: [InputMethodManagerWrapper.java:27] Constructor
 01-29 12:10:49.711 10853-10853/com.cws.advisorymandi D/cr_Ime: [ImeAdapter.java:241] attach
 01-29 12:10:49.711 10853-10853/com.cws.advisorymandi W/art: Attempt to remove local handle scope entry from IRT, ignoring
 01-29 12:10:49.716 10853-10853/com.cws.advisorymandi W/AwContents: onDetachedFromWindow called when already detached. Ignoring
 01-29 12:10:49.717 10853-10853/com.cws.advisorymandi D/cr_Ime: [InputMethodManagerWrapper.java:56] isActive: false …
Run Code Online (Sandbox Code Playgroud)

user-interface multithreading android android-asynctask android-fragments

13
推荐指数
1
解决办法
924
查看次数

如何在底部导航视图中添加分隔线

我正在尝试在BottomNavigationView的菜单项中添加分隔

所有项目都在底部水平显示,但我无法在其中添加分隔符.

底部导航视图xml:

<android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:focusable="false"
        app:itemBackground="@color/colorPrimaryDark"
        app:itemIconTint="@color/bottom_navigation_selector"
        app:itemTextColor="@color/bottom_navigation_selector"
        app:layout_anchor="@id/container"
        app:layout_anchorGravity="bottom"
        app:menu="@menu/bottom_nav_items" />
Run Code Online (Sandbox Code Playgroud)

和bottom_nav_items.xml:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:id="@+id/menu_family"
    android:checked="false"
    android:icon="@drawable/family"
    android:title="@string/family" />
<item
    android:id="@+id/menu_me"
    android:checked="false"
    android:icon="@drawable/me"
    android:title="@string/me" />

<item
    android:id="@+id/menu_blank"
    android:checkable="false"
    android:enabled="false"
    android:title="" />
<item
    android:id="@+id/menu_event"
    android:checked="false"
    android:icon="@drawable/event"
    android:title="@string/event" />
<item
    android:id="@+id/menu_more"
    android:checked="false"
    android:icon="@drawable/more"
    android:title="@string/more" />
Run Code Online (Sandbox Code Playgroud)

感谢您的支持.

android menuitem bottomnavigationview

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

任务“:app:processDebugGoogleServices”执行失败。&gt; 找不到包名称“com.example.myapp”的匹配客户端

  • 出了什么问题:任务“:app:processDebugGoogleServices”执行失败。

找不到包名称“com.example.myapp”的匹配客户端

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。

这是来自 Google Service.json 的客户端部分

“客户端”:[/sf/ask/4673654541/ {

  "client_info": {

"mobilesdk_app_id": "1:110944006455:android:f790b09ad0563a63046ab2",
"android_client_info": {
  "package_name": "com.example.myapp"
}
}
Run Code Online (Sandbox Code Playgroud)

这是我的 build.gradle

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.riderapp "
    minSdkVersion 16
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}
Run Code Online (Sandbox Code Playgroud)

您可以看到两者的应用程序 ID 相同。但我收到此错误:

  • 出了什么问题:任务执行失败:app:processDebugGoogleServices

找不到包名称“com.example.myapp”的匹配客户端

android ios dart firebase flutter

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

仅使用Twilio接听一小时的来电

Twilio在我的Android应用程序中实现了传出和传入呼叫.但是我在使用后台服务接听来电时遇到了问题.问题是我只能在前30-40分钟接听电话.一段时间后,电话停止接听来电.我试了这么多.请尽快回复我.我也和你分享代码.

我从后台服务获取令牌,后台服务在一段时间后生成令牌.

IncomingCallService.java

public class IncomingCallService extends Service implements LoginListener,
    BasicConnectionListener, BasicDeviceListener, View.OnClickListener,
    CompoundButton.OnCheckedChangeListener,
    RadioGroup.OnCheckedChangeListener {

private static Handler handler, handler_login;
public IncomingPhone phone;
SharedPreferences login_details;
Vibrator vibrator;
Ringtone r;
Uri notification;
public static final String LOGIN_DETAILS = "XXXXXXXX";
AudioManager am;
Intent intent;
public static String DEFAULT_CLIENT_NAME = "developer";
static String Twilio_id = "",
        INCOMING_AUTH_PHP_SCRIPT = MenuItems.INCOMING_AUTH_PHP_SCRIPT
                + MenuItems.Twilio_id;
Runnable newrun;
Activity context;
Context ctx;
static String op_id = "";

@Override
public IBinder onBind(Intent intent) {
    // TODO …
Run Code Online (Sandbox Code Playgroud)

service android twilio android-alertdialog

6
推荐指数
0
解决办法
340
查看次数

无法在 android 的通知抽屉中展开通知

在这里,我将消息显示到自定义通知中,但我无法使其可展开。如果我显示长文本消息,它会从结尾处被剪掉。到目前为止,我已经尝试了很多事情:

  Bitmap icon = BitmapFactory.decodeResource(this.getResources(), R.mipmap.ic_launcher);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        mBuilder.setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle("New message from " + chatContacts.getName())
                .setContentText("")
                .setLargeIcon(icon)
                .setAutoCancel(true)
                .setWhen(System.currentTimeMillis())
                .setStyle(new NotificationCompat.InboxStyle()
                        .setBigContentTitle("" + message)
                        .setSummaryText("New message from " + chatContacts.getName()))
                .setContentIntent(contentIntent);
    } else if (Build.VERSION_CODES.M >= Build.VERSION_CODES.KITKAT) {
        NotificationCompat.InboxStyle inboxStyle =
                new NotificationCompat.InboxStyle();
        String[] events = new String[6];
        inboxStyle.setBigContentTitle("Event tracker details:");
        inboxStyle.addLine(message);
        mBuilder.setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(chatContacts.getName())
                .setAutoCancel(true)
                .setStyle(inboxStyle)
                .setWhen(System.currentTimeMillis())
                .setContentIntent(contentIntent);
    } else {
        mBuilder.setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(getString(R.string.app_name))
                .setCustomBigContentView(contentView)
                .setWhen(System.currentTimeMillis()).setAutoCancel(true)
                .setContentIntent(contentIntent);
    }
    NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle(); …
Run Code Online (Sandbox Code Playgroud)

android push-notification

5
推荐指数
1
解决办法
2106
查看次数

如何在 Android 中更改 Google 地图的颜色

在这里,我试图将谷歌地图的颜色从白色改为黑色,但没有得到很好的解决方案。我尝试通过在它上面使用相对布局来改变它,但它隐藏了那个部分,它不会改变GoogleMap.

            <fragment xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/map"
                class="com.google.android.gms.maps.MapFragment"
                android:layout_width="match_parent"
                android:layout_height="100dp" />
Run Code Online (Sandbox Code Playgroud)

android google-maps android-maps-v2

3
推荐指数
1
解决办法
6760
查看次数

如何在 Android RecyclerView 中显示一组项目上方的日期/日期

您好,我在 JSONArray 中获取数据为:

{ "chatArray": [
    {
        "msg_id": "193",
        "user_id": "15235",
        "first_name": "Vishal",
        "user_name": "vishal13",
        "message": "twilio",
        "chat_time": "2017-06-30 11:28:00"
    },
    {
        "msg_id": "192",
        "user_id": "15321",
        "first_name": "Rohit",
        "user_name": "rohit12",
        "message": "how are you?",
        "chat_time": "2017-06-30 11:28:00"
    }]}
Run Code Online (Sandbox Code Playgroud)

我在 a 中显示完整的数据,RecyclerView现在我的要求是我想像 whatsapp 一样显示他们上面的日子的标题。

public ChatScreenAdapter(Activity con, List<EquityDetails> list, String senderImage, String receiverImage) {
    this.items = list;
    this.context = con;
    this.senderImage = senderImage;
    this.receiverImage = receiverImage;
    this.arraylist = new ArrayList<EquityDetails>();
    this.arraylist.addAll(items);
    if (con != null) {
        typeface_normal = Typeface.createFromAsset(con.getAssets(), …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

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