小编Ada*_*rsh的帖子

Android:底部导航视图 - 更改所选项目的图标

BottomNavigationView在我的应用程序中添加了像.

main.xml中

<android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:itemBackground="@color/colorPrimary"
        app:itemIconTint="@color/white"
        app:itemTextColor="@color/white"
        app:menu="@menu/bottom_navigation_main" />
Run Code Online (Sandbox Code Playgroud)

bottom_navigation_main.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_favorites"
        android:enabled="true"
        android:icon="@drawable/ic_favorite_white_24dp"
        android:title="@string/text_favorites"
        app:showAsAction="ifRoom" />
    <item
        android:id="@+id/action_schedules"
        android:enabled="true"
        android:icon="@drawable/ic_access_time_white_24dp"
        android:title="@string/text_schedules"
        app:showAsAction="ifRoom" />
    <item
        android:id="@+id/action_music"
        android:enabled="true"
        android:icon="@drawable/ic_audiotrack_white_24dp"
        android:title="@string/text_music"
        app:showAsAction="ifRoom" />
</menu>
Run Code Online (Sandbox Code Playgroud)

MainActivity点击

bottomNavigationView.setOnNavigationItemSelectedListener(
        new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.action_favorites:
                        //need change icon of favotites here.
                    case R.id.action_schedules:

                    case R.id.action_music:

                }
                return true;
            }
        });
Run Code Online (Sandbox Code Playgroud)

我想更改所选位置底部导航的图标.当用户点击一个项目时,我们如何实现此功能?

(如果用户点击了一个项目,那么图标会变为另一个项目)

android android-layout android-support-library bottomnavigationview

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

Android:在TextInputLayout中的EditText右侧显示TextView

我正在尝试创建如下图所示的布局在此输入图像描述

在上图中,密码字段位于TextInputLayout中,右侧还有一个TextView,指向忘记密码活动.

我使用相对布局,在没有TextInpt布局的情况下使用Textview实现EditText,如下所示

在此输入图像描述

代码 - xml文件

        <EditText
            android:id="@+id/email_address"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawableLeft="@drawable/ic_email"
            android:drawableStart="@drawable/ic_email"
            android:drawablePadding="10dp"
            android:hint="@string/email_address"
            android:textSize="14sp"
            android:maxLines="1"
            android:inputType="textEmailAddress" />



        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

        <EditText
            android:id="@+id/etxt_password_login"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawableLeft="@drawable/ic_password"
            android:drawableStart="@drawable/ic_password"
            android:drawablePadding="10dp"
            android:textSize="14sp"
            android:hint="Password"
            android:layout_alignParentLeft="true"
            android:inputType="textPassword"
            android:maxLines="1"/>

            <TextView
                android:id="@+id/txt_forget_password"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:text="forget ?"
                android:textSize="12sp"
                android:layout_marginRight="10dp"
                android:textColor="#808080"
                />

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

但是,如果我在EditText中添加TextInputLayout,我无法实现它..尝试并搜索了很多.

?我们如何解决上述问题

谢谢..

android android-layout android-edittext android-textinputlayout

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

react-native:无法从''.../node_modules/window-size/index.js解析模块`tty`:模块映射中不存在模块

错误

    loading dependency graph, done.
    error: bundling failed: Error: Unable to resolve module `tty` from `/MyWorks/rnTestTrials/myCurrencySample/node_modules/window-size/index.js`: Module does not exist in the module map

    This might be related to https://github.com/facebook/react-native/issues/4968
    To resolve try the following:
      1. Clear watchman watches: `watchman watch-del-all`.
      2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
      3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.  
      4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
        at ModuleResolver.resolveDependency (/MyWorks/rnTestTrials/myCurrencySample/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:158:1476)
        at ResolutionRequest.resolveDependency (/MyWorks/rnTestTrials/myCurrencySample/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:92:16)
        at DependencyGraph.resolveDependency …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-native-android react-native-ios

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

React-native :Android Debug 版本不会从 react-native 资产文件夹加载图像资产

出于测试和共享目的,我在终端中使用以下代码创建了一个 apk

react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debugScanning
Run Code Online (Sandbox Code Playgroud)

并使用创建 apk

Create debug build:
cd android
./gradlew assembleDebug
Run Code Online (Sandbox Code Playgroud)

上面的解决方案来自成功创建一个好的 apk 文件的 stackoverflow,

但是,当我测试 apk 时,它没有显示文件夹中的图标

"react-native-project-name/assets" 
Run Code Online (Sandbox Code Playgroud)

只显示空白而不是图标。测试了一些解决方案,但注意解决了这个问题。

版本

react-native-cli: 2.0.1
react-native: 0.55.4
Run Code Online (Sandbox Code Playgroud)

android android-build react-native react-native-android

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

Retrofit2:上传带有一些表单数据的图像-Android

邮递员截图

上面的屏幕截图包含来自服务器的 Post 方法和响应..在这里我试图将带有一些数据的图像上传到我的服务器(从图库或相机中获取图像)。

我正在尝试通过改造 2 来实现这一点。从互联网上尝试一些方法......但我无法找到正确的方法来完成它

新的改造2。所以我不能这样做。

如何创建retrofit2接口并处理响应..请帮忙

编辑我的尝试

活动中的代码

  ProofAPI service =  retrofit.create(ProofAPI.class);
        File file=new File(sdCard.getAbsolutePath()+fNameAd);
        MultipartBody.Part filePart = MultipartBody.Part.createFormData("proof", file.getName(), RequestBody.create(MediaType.parse("image/*"), file));

 HashMap<String, String> map = new HashMap<>();
        map.put("userId", user_id);
        map.put("proofDocId", idproofno);
        map.put("proofFilename", proofFilename);
        map.put("docType", docType);
    Call<ProofResp> call = service.uploadFileWithPartMap(map,filePart);
        call.enqueue(new Callback<ProofResp>() {
            @Override
            public void onResponse(Call<ProofResp> call, Response<ProofResp> response) {
                Toast.makeText(getApplicationContext(),response.body().getMessage(),Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onFailure(Call<ProofResp> call, Throwable t) {
                Toast.makeText(getApplicationContext(),"fjkds",Toast.LENGTH_SHORT).show();
            }
        });
Run Code Online (Sandbox Code Playgroud)

Retofit2 接口 -> ProofAPI

@Multipart
    @POST("rest-proof-upload")
    Call<ProofResp> uploadFileWithPartMap(
            @PartMap() Map<String, String> partMap,
            @Part MultipartBody.Part …
Run Code Online (Sandbox Code Playgroud)

android json image retrofit retrofit2

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