小编Thu*_*der的帖子

如何在Android应用程序中的活动之间传递数据?

我有一个场景,通过登录页面登录后button,每个都会有一个注销activity.

点击后sign-out,我将通过session id已登录用户登出.任何人都可以指导我如何让session id所有人都可以使用activities吗?

任何替代这种情况

android android-intent android-activity

1293
推荐指数
29
解决办法
88万
查看次数

134
推荐指数
4
解决办法
20万
查看次数

在NestedScrollView中,RecycleView窃取焦点

当我将RecyclerView放在嵌套的scrollview中时,屏幕总是跳到RecyclerView的顶部而不是页面的顶部.这是一个简单的例子.

layout xml:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="350dp"
            android:background="@android:color/holo_blue_dark"/>
        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycleView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
</android.support.v4.widget.NestedScrollView>
</layout>
Run Code Online (Sandbox Code Playgroud)

虚拟适配器的活动:

public class RecycleViewTestActivity extends AppCompatActivity {

public static class ExampleAdapter extends RecyclerView.Adapter<ExampleViewHolder> {

    private Context context;

    public ExampleAdapter(Context context) {
        this.context = context;
    }

    @Override
    public ExampleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        TextView view = new TextView(context);
        view.setText("Test");
        return new ExampleViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ExampleViewHolder holder, int position) {

    } …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-recyclerview

42
推荐指数
4
解决办法
2万
查看次数

如何在xml中设置形状的背景?

我刚刚使用android形状创建了一个红色圆圈:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadiusRatio="4"
    android:shape="ring"
    android:thicknessRatio="9"
    android:useLevel="false" >

     <solid android:color="#FF0000" />

    <size
        android:height="48dip"
        android:width="48dip" />

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

这真的很酷,但我无法将圆圈的背景颜色设置为我的颜色.我尝试过,android:background="#FFFFFF"但在我的布局中看起来总是黑色.如何设置上述形状的背景?

android background colors shape android-drawable

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

如何使用粗体字体创建自定义字体系列

我正在尝试使用此文档创建自定义字体系列https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml.html问题在于没有加粗属性和我不能以编程方式在XML中设置字体?

android

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

扩展BaseObservable的ViewModel和Android ViewModel Class有什么区别?

我目前正在研究MVVM架构模式,但我在扩展BaseObservable的Custom ViewModel类和Android本身提供的另一个ViewModel之间感到困惑.

java android mvvm viewmodel observable

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

如何在NestedScrollView中实现ConstraintLayout

如果TextView的文本比水平LinearLayout中包含的其他TextView少得多,则ConstraintLayout表现不一致.如果左边的一个角色TextView不比正确的角色少,TextView那么它的效果很好.请参阅附加截图中的红色文字和绿色文字. 越野车屏幕所需的屏幕

下面是布局的XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/color_F1F1F1"
    android:padding="10dp">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:padding="10dp">

        <TextView
            android:id="@+id/tv_name_header"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/employee_name"
            android:textColor="@color/color_999999"
            android:textSize="12sp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/tv_date_header"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/date"
            android:textColor="@color/color_999999"
            android:textSize="12sp"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />


        <TextView
            android:id="@+id/tv_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            android:textColor="@color/black"
            android:textSize="14sp"
            android:textStyle="bold"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tv_name_header" />

        <TextView
            android:id="@+id/tv_date"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            android:textColor="@color/black"
            android:textSize="14sp"
            android:textStyle="bold"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tv_date_header" />

        <TextView
            android:id="@+id/tv_role_header"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="@string/employee_role"
            android:textColor="@color/color_999999"
            android:textSize="12sp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tv_name" />

        <TextView
            android:id="@+id/tv_band_header"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="@string/employee_band" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-constraintlayout

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

如何从终端打开Android SDK管理器?

我已经安装了Android Studio和SDK工具。现在的问题是,当我尝试从终端打开sdkmanager时,它没有打开任何东西。它说完成更新100%,但没有打开任何东西并卡住。以下是终端中的输出:

ARSLAANs-MBP:bin arslaan $ sdkmanager
[======================================= %计算更新...

注意:SDK工具目录和JAVA_HOME被添加为环境变量

请帮忙,谢谢

android android-sdk-manager

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

如何在模拟器上显示地图

在Android Studio中,我创建了一个Map Activity项目。因此,没有自定义代码。

唯一的自定义更改是从google_maps_api.xml _(https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=) _ 复制URL 并使用它来创建API密钥。

Android Studio:3.0.1仿真器:具有API 25的Nexus 5X

Build.gradle文件

应用插件:“ com.android.application”

应用插件:“ kotlin-android”

应用插件:“ kotlin-android-extensions”

android {
    编译版本26
    defaultConfig {
        applicationId“ xxxx.xxx.xxxx”
        minSdkVersion 19
        targetSdkVersion 26
        版本代码1
        versionName“ 1.0”
        testInstrumentationRunner“ android.support.test.runner.AndroidJUnitRunner”
    }
    buildTypes {
        发布 {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
        }
    }
}

依赖项{
    实现fileTree(dir:'libs',包括:['* .jar'])
    实现“ org.jetbrains.kotlin:kotlin-stdlib-jre7:$ kotlin_version”
    实施'com.android.support:appcompat-v7:26.1.0'
    实施'com.google.android.gms:play-services-maps:11.0.0'
    testImplementation'junit:junit:4.12'
    androidTestImplementation'com.android.support.test:runner:1.0.1'
    androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.1'
}

屏幕截图

在此处输入图片说明

好像我在想什么。我只是不知道那是什么。

android android-maps-v2 android-studio

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

如何获取动态节点JSON值

   {       
        noteCount_xxx:
              {
              favorite:"favorite-border",
              id:"noteCount_xxx",
              note:"noteContent",
              title: "notetitle",
            }
    }
Run Code Online (Sandbox Code Playgroud)
  • 这个在运行时创建的JSON数据,
  • 父母noteCount_xxx是动态的
  • 我想获得该父节点的值
  • 输出将是

    {favorite:"favorite-border",id:"noteCount_xxx",注意:"noteContent",标题:"notetitle"}

我无法从动态节点获取数据,获取该数据的最佳方法是什么?

javascript json

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