Questions tagged «android»

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

7
Android-可绘制,仅在顶部带有圆角
我有一个可绘制的背景,有一个圆角的矩形: <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/white" /> <stroke android:width="1dp" android:color="@color/light_gray" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> <corners android:radius="6dp" /> </shape> 如预期的那样,这工作正常。 现在,我想将其更改为仅圆角,因此将其更改为: <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/white" /> <stroke android:width="1dp" android:color="@color/light_gray" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> <corners android:topLeftRadius="6dp" android:topRightRadius="6dp" android:bottomLeftRadius="0dp" android:bottomRightRadius="0dp"/> </shape> 但是现在没有一个角是圆的,我得到一个普通的矩形。我在这里想念什么?

30
紧急:AVD系统路径损坏。检查您的ANDROID_SDK_ROOT值
输入cordova run android终端后,出现此错误: Waiting for emulator to start... PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/Users/username/Library/Android/sdk]! 导出后会发生这种情况: export ANDROID_SDK_ROOT='/Users/username/Library/Android/sdk' 在导出之前,我得到了: Waiting for emulator to start... PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT 有什么想法我要去哪里吗?我确定这是sdk根目录,为什么我会损坏avd系统路径?
151 android  cordova 

30
Android设备选择器-我的设备似乎离线
我已经开发了一个应用程序,并且打算将其部署到我的HTC Desire中。我已经安装了USB驱动程序。我打开了手机上的USB调试功能,仅在插入手机后才选择充电。当我运行应用程序时,Android设备选择器使我的设备脱机。我被困在这一点上。任何帮助,将不胜感激。 我在Windows 7(64位)上的Eclipse Helios上进行开发

13
从两个类扩展
我怎样才能做到这一点: public class Main extends ListActivity , ControlMenu 另外,我想知道这种方法是否可行,因为我已经在类中创建了菜单,即ControlMenu,并且我将在其余的活动中进行扩展。
150 java  android 

30
Android Studio将R标记为红色,并显示错误消息“无法解析符号R”,但构建成功
想要改善这篇文章吗?提供此问题的详细答案,包括引文和答案正确的解释。答案不够详细的答案可能会被编辑或删除。 在我尝试在Android Studio中创建的每个项目中,R的所有用法都标记为红色,并带有错误消息“无法解析符号R”,但是编译成功并且应用程序运行。这真的很烦人,因为它会阻止自动完成,并在我的代码中显示巨大的红色波浪线。 我正在运行Android Studio 1.7.0,并使用默认设置创建项目。附有屏幕截图: 这是我的build.gradle: buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.4' } } apply plugin: 'android' dependencies { compile files('libs/android-support-v4.jar') } android { compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig { minSdkVersion 7 targetSdkVersion 16 } } 这是项目结构的样子: 任何想法如何解决这个问题?

6
android从服务开始活动
Android: public class LocationService extends Service { @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); startActivity(new Intent(this, activity.class)); } } 我从 Activity 在Activity如果条件满足启动 startService(new Intent(WozzonActivity.this, LocationService.class)); 从我LocationService上面提到的无法启动Activity,如何获取当前正在Activity服务类中运行的上下文?

20
公式px到dp,dp到px android
我正在尝试计算可变数量的像素到与密度无关的像素,反之亦然。 该公式(px to dp): dp = (int)(px / (displayMetrics.densityDpi / 160));不适用于小型设备,因为它被零除。 这是我的dp至px公式: px = (int)(dp * (displayMetrics.densityDpi / 160)); 有人可以给我一些指示吗?

2
onNewIntent()生命周期和注册的侦听器
我正在使用singleTop活动来通过接收来自搜索对话框的意图onNewIntent()。 我注意到的是onPause()在调用之前onNewIntent(),然后调用它onResume()。视觉上: 搜索对话框启动 向活动触发搜索意图 onPause() onNewIntent() onResume() 问题是我在中注册了侦听器,但onResume()已将其删除onPause(),但在onNewIntent()通话中需要它们。有没有使这些监听器可用的标准方法?

5
如何更改ViewPager的页面?
我在我的应用程序中使用ViewPager,并在主Activity中对其进行定义。在onCreate方法内部,我从SharedPreferences加载了一些页面,然后将其传递给PagerAdapter: @Override public int getCount() { return numberOfPages; } 问题是,如果我将“偏好设置”(或其他“活动”)中的该数字更改为我之前查看过的其他页面索引,则我的应用程序将崩溃,因为当我使用此ViewPager返回到活动时,此索引超出范围。只需更改活动ViewPager的页面即可对其进行修复。有什么办法吗?

4
Android ClickableSpan不调用onClick
我正在创建一个ClickableSpan,它正确显示并带有下划线的正确文本。但是,单击未注册。你知道我在做什么错吗??? 谢谢,维克多 这是代码片段: view.setText("This is a test"); ClickableSpan span = new ClickableSpan() { @Override public void onClick(View widget) { log("Clicked"); } }; view.getText().setSpan(span, 0, view.getText().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
150 android  textview 

12
如何摆脱增量注释处理请求的警告?
我刚刚开始使用android开发并尝试使用Room库。从昨天开始我就面临着这个警告信息 w:[kapt]请求了增量注释处理,但是由于以下处理器不是增量处理器而被禁用:androidx.lifecycle.LifecycleProcessor(NON_INCREMENTAL),androidx.room.RoomProcessor(NON_INCREMENTAL)。 我试图研究和修复,但无法避免此错误,这是我的grale.build文件。请提出建议/建议我在做什么错。 apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { applicationId "ps.room.bookkeeper" minSdkVersion 15 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" javaCompileOptions { annotationProcessorOptions { arguments = ["room.schemaLocation":"$projectDir/schemas".toString()] } } buildTypes { release { minifyEnabled false …

14
无法连接远程调试器
我正在使用React.JS,当我这样做时react-native run-android(插入设备),我看到一个空白页。当我摇动设备并Debug JS Remotely从选项列表中进行选择时,会看到以下屏幕。 仅供参考: OS: Ubuntu 16.04 Node version is: v4.6.2 java version "1.8.0_111" react": "15.4.1 react-native": "0.38.0


3
将InputStream转换为BufferedReader
我正在尝试使用InputStream从Android的Assets目录中逐行读取文本文件。 我想将InputStream转换为BufferedReader以便能够使用readLine()。 我有以下代码: InputStream is; is = myContext.getAssets().open ("file.txt"); BufferedReader br = new BufferedReader (is); 第三行删除以下错误: 这行有多个标记 构造函数BufferedReader(InputStream)未定义。 我想要在C ++中做的事情是这样的: StreamReader file; file = File.OpenText ("file.txt"); line = file.ReadLine(); line = file.ReadLine(); ... 我在做什么错或应该怎么做?谢谢!


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.