Questions tagged «android»

Android是Google的移动操作系统,用于对数字设备(智能手机,平板电脑,汽车,电视,Wear,Glass和IoT)进行编程或开发。对于与Android相关的主题,请使用特定于Android的标签,例如android-intent,android-activity,android-adapter等。对于与开发或编程无关但与Android框架相关的问题,请使用以下链接:https:// android.stackexchange.com。


4
如何从styles.xml中以编程方式检索样式属性
目前,我正在使用WebView或TextView在我的一个应用程序中显示一些来自Web服务的动态数据。如果数据包含纯文本,它将使用TextView并应用来自styles.xml的样式。如果数据包含HTML(主要是文本和图像),则使用WebView。 但是,此WebView是未设置样式的。因此,它看起来与通常的TextView有很大不同。我已经读到,只需在数据中直接插入一些HTML,就可以在WebView中设置文本样式。这听起来很容易,但是我想将Styles.xml中的数据用作此HTML中所需的值,因此如果更改样式,则无需在两个位置更改颜色等。 那么,我该怎么做呢?我已经进行了广泛的搜索,但没有找到从您的styles.xml中实际检索不同样式属性的方法。我是否在这里缺少某些东西,还是真的无法检索这些值? 我尝试从中获取数据的样式如下: <style name="font4"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:textSize">14sp</item> <item name="android:textColor">#E3691B</item> <item name="android:paddingLeft">5dp</item> <item name="android:paddingRight">10dp</item> <item name="android:layout_marginTop">10dp</item> <item name="android:textStyle">bold</item> </style> 我主要对textSize和textColor感兴趣。
81 android  xml  styles 

7
在RecyclerView中的行内单击处理按钮
我正在使用以下代码来处理行点击。(来源) static class RecyclerTouchListener implements RecyclerView.OnItemTouchListener { private GestureDetector gestureDetector; private ClickListener clickListener; public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final ClickListener clickListener) { this.clickListener = clickListener; gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return true; } @Override public void onLongPress(MotionEvent e) { View child …

6
(改进)无法找到类崩溃应用的转换器
因此,Retrofit 2.0.0是最近发布的,实际上没有任何有关如何使用它的更新示例,而是我试图通过基本的API调用来实现它。我正在 java.lang.IllegalArgumentException: Unable to create converter for class` 由...引起 Caused by: java.lang.IllegalArgumentException: Could not locate converter for class orbyt.app.dataclass. Tried: * retrofit.OkHttpBodyConverterFactory 尝试进行api调用时。
81 java  android  retrofit 

2
在Android中声明可样式化的属性
关于declare-styleable标签的宝贵文档很少,我们可以通过这些标签声明组件的自定义样式。我确实找到了标签属性的有效值列表。尽管这很好,但并没有说明如何使用其中一些值。浏览attr.xml(标准属性的Android源)时,我发现您可以执行以下操作:formatattr <!-- The most prominent text color. --> <attr name="textColorPrimary" format="reference|color" /> 的 format属性显然可以设置为值的组合。大概该format属性可以帮助解析器解释实际的样式值。然后我在attr.xml中发现了这一点: <!-- Default text typeface. --> <attr name="typeface"> <enum name="normal" value="0" /> <enum name="sans" value="1" /> <enum name="serif" value="2" /> <enum name="monospace" value="3" /> </attr> <!-- Default text typeface style. --> <attr name="textStyle"> <flag name="normal" value="0" /> …

5
不推荐使用Dagger 2.2组件构建器模块方法
我开始使用dagger 2.2,并且不赞成使用“组件”构建器中的模块方法。 这是我的应用程序组件: @Component(modules = ApplicationModule.class) public interface ApplicationComponent { void inject(Application application); } 和应用程序模块: @Module public class ApplicationModule { Application application; public ApplicationModule(Application application) { this.application = application; } @Provides @Singleton Application providesApplication() { return application; } } 这是生成的类: @Generated( value = "dagger.internal.codegen.ComponentProcessor", comments = "https://google.github.io/dagger" ) public final …
81 android  dagger-2 

13
如何在Windows 8上针对API 21和19在没有硬件加速的情况下为Intel x86 Atom运行Android仿真器?
我尚未启用Hyper V或硬件加速,也不想。 有什么办法可以在Windows 8上没有硬件加速的情况下为Intel x86 Atom启动android仿真器 我创建了具有所有可能组合的AVD,但每个组合都无法启动AVD模拟器实例,因此在启动时会抛出相同的错误 仿真器:错误:x86仿真当前需要硬件加速!请确保正确安装了英特尔HAXM并可以使用它。CPU加速状态:未安装HAX内核模块! 或者是,如果没有针对API 21和19的硬件加速和hyper V,为Intel Atom 86和64提供的映像将无法运行 我发现了很多类似的问题,并且阅读了几乎所有文档,但是尚不清楚它们是否可以在没有hyper v和硬件加速的情况下运行或无法运行,因此直接 在这种情况下,您如何在android上进行测试?


3
什么是Android UiThread(UI线程)
有人可以向我解释一下UI线程到底是什么吗?在developer.android.com上说到runOnUiThread函数 public final void runOnUiThread(可运行操作) 从以下版本开始:API级别1在UI线程上运行指定的操作。如果当前线程是UI线程,则立即执行该操作。如果当前线程不是UI线程,则将操作发布到UI线程的事件队列。 UI线程是否意味着每次通过诸如呼叫或屏幕变暗等ui活动将活动推到后台时,都将运行该线程?如果不是,那么UI线程到底包含什么? 谢谢

7
如何在string.xml文件中放置“-”
我需要能够在strings.xml文件中的字符串中添加“-” 。 我的问题是,当我放置字符串"1261eba2-9d8c-11e1-93e3-40409e0f44a1"eclipse时会大喊: 在此行发现多个注释:-用“破折号”字符替换“-”(–,&;#8211;) 我怎样才能解决这个问题?
81 android  string 

11
java.lang.NullPointerException(无错误消息)
我知道这个问题已经被问过很多次了,我的确回答了大多数问题,但是没有一个对我有帮助。所以这是我的问题,每当我同步项目时,它总是失败。以下是gradle控制台的外观: 执行任务:[:app:generateDebugSources,:app:generateDebugAndroidTestSources,:app:mockableAndroidJar,:app:prepareDebugUnitTestDependencies] 按需配置是一个孵化功能。增量Java编译是一个令人振奋的功能。:app:preBuild UP-TO-DATE:app:preDebugBuild UP-TO-DATE:app:checkDebugManifest:app:preReleaseBuildUP-TO-DATE:app:prepareComAndroidSupportAnimatedVectorDrawable2420Library UP-TO-DATE:app:prepareComAndroidSupportAppcompatV72420DATE:UP: app:prepareComAndroidSupportDesign2420Library UP-TO-DATE:app:prepareComAndroidSupportMediarouterV72300Library UP-TO-DATE:app:prepareComAndroidSupportRecyclerviewV72420Library UP-TO-DATE:app:prepareComAndroidSupportSupportAppat2420Library UPTO-pre-Com-UATEDate:App:prepareCom-Android:截止日期:app:prepareComAndroidSupportSupportFragment2420Library截止日期:app: 出了什么问题:java.lang.NullPointerException(无错误消息) 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行,以获取更多日志输出。 建立失败 总时间:7.518秒 这些是我的依赖 dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:design:24.2.0' compile 'com.google.android.gms:play-services:9.4.0' testCompile 'junit:junit:4.12' compile 'com.google.android.gms:play-services-location:9.4.0' compile 'com.google.android.gms:play-services-appindexing:9.4.0' compile 'com.google.firebase:firebase-messaging:9.2.0' compile 'com.google.firebase:firebase-database:9.0.2' compile 'com.firebase:firebase-client-android:2.4.0' compile …


20
Gradle buildConfigField BuildConfig无法解析符号
我正在使用Gradle构建我的Android应用程序。我正在尝试根据构建类型(发布或调试)使用一些标志。 我的Gradle文件如下所示: android { buildTypes { debug { buildConfigField 'boolean', 'PREPROD', 'true' buildConfigField 'boolean', 'STAGING', 'false' } release { buildConfigField 'boolean', 'PREPROD', 'false' buildConfigField 'boolean', 'STAGING', 'false' } } } 并且,如果我尝试致电,BuildConfig.PREPROD或者BuildConfig.STAGING收到“无法解析符号”错误。Gradle同步成功,所以我不知道是否忘记了一些步骤才能使用此功能? 生成的BuildConfig.java文件如下(在中build/source/buildConfig/debug/com.example.myapp): package com.example.myapp; public final class BuildConfig { public static final boolean DEBUG = Boolean.parseBoolean("true"); public static final String …

13
名称为[DEFAULT]的FirebaseApp不存在
迁移到Firebase Cloud Messaging之后。打开应用程序时,它崩溃并引发错误,提示java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.我已经放置了新的google-services.json并更新了我的SDK。 这是我的MainActivity public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Check Google play service GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance(); int resultCode = googleAPI.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else { …
81 java  android  firebase 

9
如何在Android Studio中创建发布的android库包(aar)(不调试)
我已经构建了我的android库包(aar),构建结果在“ .. \ app \ build \ outputs \ aar”文件夹中创建。该文件夹中的文件称为“ app-debug.aar”,因此我猜它已在调试模式下构建,因此我想知道如何生成所构建的发行版,即“ app-release.aar”。我怎样才能做到这一点?此外,是否可以使用另一个自定义名称(例如,“ myCustomAppName-release.aar”而不是“ app-release.aar”)生成该生成。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.