小编Jis*_*ant的帖子

NDK支持不同的产品风味

我想从ndk库中获取不同的 字符串 值.因为我有两个风味演示和现场我想要价值"你好我来自演示"的演示风味和现场风味我想"你好我来自现场"

这是我的java文件代码

public class MainActivity extends AppCompatActivity {
    // Used to load the 'native-lib' library on application startup.
    static {
        System.loadLibrary("native-lib");
    }

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Example of a call to a native method
    TextView tv = (TextView) findViewById(R.id.sample_text);
    tv.setText(stringFromJNI());
}

/**
 * A native method that is implemented by the 'native-lib' native library,
 * which is packaged with this application.
 */
public native String stringFromJNI();
Run Code Online (Sandbox Code Playgroud)

}

这是我的cpp文件代码

#include <jni.h>
#include …
Run Code Online (Sandbox Code Playgroud)

c++ java android android-ndk android-productflavors

6
推荐指数
2
解决办法
1966
查看次数

AppCompatActivity 的 TextView 颜色始终为白色

TextView在 Marshmallow 之前的设备上,a 的文本颜色始终为白色。即使我在 XML 中使用黄色或黑色,除了棉花糖之外,它始终是白色的。

在运行时,它将在所有设备上正常工作。以前,当我使用 Eclipse 时,一切正常,但在 Android Studio 中它没有从 XML 中获取属性。

我搜索过的所有问题都说要更改Theme.AppCompat为Theme.AppCompat.Light,但这除了将白色更改为黑色之外没有任何作用。我认为存在风格错误。这是我的样式代码:

 <style name="AppBaseTheme" parent="Theme.AppCompat">
        <item name="colorPrimary">@color/khaki</item>
        <item name="colorPrimaryDark">@color/khaki</item>
        <item name="colorAccent">@color/my_yellow</item>

        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>
Run Code Online (Sandbox Code Playgroud)

这是我的 xml

 <?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="48dp">
   <ImageView
    android:id="@+id/icon1"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:layout_alignParentLeft="true"
    android:layout_marginLeft="12dp"
    android:layout_marginRight="12dp"
     android:src="@drawable/sj_icon"
    android:layout_centerVertical="true"/>

   <TextView
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:layout_alignLeft="@+id/icon1"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="32dp"
    android:gravity="center_vertical"
    android:minHeight="34dp"
    android:paddingLeft="7dp"
    android:text="hello" …
Run Code Online (Sandbox Code Playgroud)

android android-appcompat android-studio android-styles

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