小编Abh*_*hek的帖子

如何更改底部导航活动的菜单布局文件的设计选项卡的视图(工具:showIn)

我只想将我的设计视为底部导航视图,因此我通过设置tools:showIn="bottom_navigation_view"menu.xml文件上尝试了以下操作,但它对我的设计视图选项卡没有任何影响

我不想要的菜单视图的图像

在此处输入图片说明

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:showIn="bottom_navigation_view">

    <item
        android:id="@+id/navigation_home"
        android:icon="@drawable/ic_home_black_24dp"
        android:title="@string/title_home" />

    <item
        android:id="@+id/navigation_dashboard"
        android:icon="@drawable/ic_dashboard_black_24dp"
        android:title="@string/title_dashboard" />

    <item
        android:id="@+id/navigation_notifications"
        android:icon="@drawable/ic_notifications_black_24dp"
        android:title="@string/title_notifications" />

</menu>
Run Code Online (Sandbox Code Playgroud)

所以请建议我这样一个有价值的工具:showIn可以工作。

android android-layout android-xml android-menu android-tools-namespace

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

如何将 OkHttp 日志记录到 Crashlytics

我正在尝试使用 OkHttp 通过使用拦截登录到 Crashlytics,因为我的一些客户收到 500 错误,我想完成他们发布的内容和在响应中获得的详细信息。就像 Android Studio 的日志中显示的 OkHttp 一样。

当发生 200 错误但没有成功时,我尝试记录详细信息。

@Module
public class DIModule {

MyApplication application;

public DIModule(MyApplication application) {
    this.application = application;
}
public DIModule()
{

}

@Singleton
@Provides
OkHttpClient getOkHttpClient() {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);
    return new OkHttpClient.Builder()
            .addInterceptor(logging).addInterceptor(new HeaderInterceptor())
            .build();
}
@Singleton
@Provides
Retrofit getRetro(OkHttpClient client) {

    return new Retrofit.Builder()
            .baseUrl(Api.BASE_URL)
            .client(client)
            .addConverterFactory(GsonConverterFactory.create()) //Here we are using the GsonConverterFactory to directly convert json data to object
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())

            .build();
}

@Singleton …
Run Code Online (Sandbox Code Playgroud)

android crashlytics rx-java okhttp retrofit2

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

想要在 Button 上添加图标,drawableTop 无法在 Android 上运行

我想在Button上添加呼叫图标,但 drawableTop 不起作用。

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp">
        <Button
            android:id="@+id/imageView3"
            android:layout_width="wrap_content"
            android:drawableTop="@android:drawable/ic_menu_call"
            android:layout_height="match_parent"
            android:layout_weight="1" />
    </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

android android-layout android-button android-drawable

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

如何通过组件的引用添加Click Handler

我正在学习 React js 并想知道,可以通过组件的引用添加点击处理程序。

我尝试跟随,但没有用

import React, { Component } from 'react'

export default class RefsDemo extends Component {
  constructor(props) {
    super(props)

    this.inputRef=React.createRef();
    this.buttonRef=React.createRef();
  }

  componentDidMount()
  {
      console.log(this.buttonRef);
      this.buttonRef.current.onClick=()=>this.abchandle()
  }

  abchandle()
  {
      alert('hi');
  }

    render() {
    return (
      <div>
        <button ref={this.buttonRef} >click</button>
      </div>
    )
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

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