标签: android-resources

有没有办法从APK文件中获取源代码?

我的笔记本电脑上的硬盘驱动器崩溃了,我丢失了过去两个月一直在处理的应用程序的所有源代码.我所拥有的是从我发送给朋友时存储在我的电子邮件中的APK文件.

有没有办法从这个APK文件中提取我的源代码?

android decompiling apk android-resources

1218
推荐指数
16
解决办法
102万
查看次数

R无法解析 - Android错误

我刚下载并安装了新的Android SDK.我想创建一个简单的应用程序来测试它.

该向导创建了此代码:

package eu.mauriziopz.gps;

import android.app.Activity;
import android.os.Bundle;

public class ggps extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
Run Code Online (Sandbox Code Playgroud)

Eclipse给了我错误

R无法解决

在线

setContentView(R.layout.main);
Run Code Online (Sandbox Code Playgroud)

为什么?

PS:我有一个名为XML文件main.xmlres/layout/.

eclipse android compiler-errors android-sdk-tools android-resources

1056
推荐指数
28
解决办法
89万
查看次数

在Android 6.0 Marshmallow(API 23)上弃用了getColor(int id)

Resources.getColor(int id)方法已被弃用.

@ColorInt
@Deprecated
public int getColor(@ColorRes int id) throws NotFoundException {
    return getColor(id, null);
}
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

android android-resources android-mnc android-6.0-marshmallow

686
推荐指数
12
解决办法
27万
查看次数

Android getResources().getDrawable()已弃用API 22

新的Android API 22 getResources().getDrawable()现已弃用.现在最好的方法是只使用getDrawable().

改变了什么?

android android-resources android-drawable android-5.1.1-lollipop

672
推荐指数
7
解决办法
35万
查看次数

Android drawable目录可以包含子目录吗?

在Android SDK文档中,与@ drawable/my_image xml语法一起使用的所有示例都直接处理存储在项目的res/drawable目录中的图像.

我想知道在drawable目录中创建子目录是否明确不可行.

例如,如果我有以下目录布局:

res/drawable
-- sandwiches
  -- tunaOnRye.png
  -- hamAndSwiss.png
-- drinks
  -- coldOne.png
  -- hotTea.png
Run Code Online (Sandbox Code Playgroud)

我可以参考金枪鱼沙拉三明治的图像@ drawable/sandwiches/tunaOnRye

或者我必须将层次结构保持在drawable目录中.

android drawable android-resources

471
推荐指数
10
解决办法
14万
查看次数

定义自定义attrs

我需要实现自己的属性,如in com.android.R.attr

在官方文档中找不到任何内容,因此我需要有关如何定义这些attrs以及如何在我的代码中使用它们的信息.

android android-resources android-attributes

449
推荐指数
4
解决办法
23万
查看次数

使用String.xml的动态字符串?

是否可以在字符串值中包含占位符string.xml,可以在运行时分配值?

例:

一些字符串PLACEHOLDER1更多字符串

string android string-formatting android-resources

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

不推荐使用getResources().getColor()

使用: buildToolsVersion "22.0.1", targetSdkVersion 22在我的gradle文件中.

我发现有用的getResources().getColor(R.color.color_name)是不推荐使用的.

我应该用什么呢?

android deprecated android-resources android-color

349
推荐指数
4
解决办法
17万
查看次数

从android项目中删除所有未使用的资源

我想从我的Android res目录中删除所有未使用的布局,字符串,drawable,颜色等.是否有任何工具可以为我提供文件列表,我可以从我的存储库中删除不再使用的特定文件(例如,未使用的字符串条目)中的元素?

android android-resources

346
推荐指数
10
解决办法
15万
查看次数

从源代码中加载res/values/dimension.xml中的维度值

我想按原样加载值.我有两个dimension.xml文件,一个在/res/values/dimension.xml,另一个在/res/values-sw360dp/dimension.xml.

从源代码我想做的事情

getResources().getDimension(R.dimen.tutorial_cross_marginTop);
Run Code Online (Sandbox Code Playgroud)

这是有效的,但我获得的值乘以屏幕密度系数(hdpi为1.5,xhdpi为2.0等).

我也试过

getResources().getString(R.dimen.tutorial_cross_marginTop);
Run Code Online (Sandbox Code Playgroud)

这原则上可行,但我得到一个以"dip"结尾的字符串......

android dpi dimension android-resources

319
推荐指数
8
解决办法
18万
查看次数