Questions tagged «android»

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

14
按钮背景为透明
我有一个按钮。当我按下按钮时,我必须将文本设置为粗体,否则会正常显示。因此,我为粗体和普通写样式。 <style name="textbold" parent="@android:style/TextAppearance"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:textStyle">bold</item> </style> <style name="textregular" parent="@android:style/TextAppearance"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:textStyle">normal</item> </style> 现在我有一个button_states.xml为: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:state_pressed="true" style="@style/textbold" /> <item android:state_focused="false" android:state_pressed="true" style="@style/textregular" /> <item style="@style/textregular" /> </selector> 在此按钮的布局中,我也必须使背景也透明...我将如何做?我的布局代码是: <Button android:id="@+id/Btn" android:background="@drawable/button_states" /> 如何在样式中加入透明背景?
177 android 

15
无法将Openssl识别为内部或外部命令
我希望为我的应用程序生成一个应用程序签名,以后将与Facebook集成。在Facebook的一篇教程中,我找到了以下命令: keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 在本教程中,它说通过运行此cmd,将开始我生成签名的过程。 但是,此命令给出错误: openssl is not recognized as an internal or external command 我该如何摆脱呢?


16
如何在Android中更改ProgressBar的进度指示器颜色
我设置了Horizo​​ntal ProgressBar。 我想将进度颜色更改为黄色。 <ProgressBar android:id="@+id/progressbar" android:layout_width="80dip" android:layout_height="20dip" android:focusable="false" style="?android:attr/progressBarStyleHorizontal" /> 问题是,进度颜色在不同的设备中是不同的。因此,我希望它可以修复进度颜色。

13
电话:用于文字输入的数字键盘
有没有一种方法可以强制数字键盘在电话上显示<input type="text">?我刚刚意识到<input type="number">HTML5中是用于“浮点数”的,因此它不适用于信用卡号,邮政编码等。 我想模拟的数字键盘功能<input type="number">,以接受采用浮点数以外的数字值的输入。也许有另一种合适的input类型吗?

1
Android Java;如何将资产文件夹中的本地JSON文件解析为ListView
我目前正在开发一个物理应用程序,该应用程序应显示公式列表,甚至可以解决其中的一些问题(唯一的问题是ListView) 这是我的主要布局 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="wrap_content" android:measureWithLargestChild="false" android:orientation="vertical" tools:context=".CatList" > <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/titlebar" > <TextView android:id="@+id/Title1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="@string/app_name" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#ff1c00" android:textIsSelectable="false" /> </RelativeLayout> <ListView android:id="@+id/listFormulas" android:layout_width="match_parent" android:layout_height="wrap_content" > </ListView> </LinearLayout> 这是我的主要活动 package com.wildsushii.quickphysics; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import org.json.JSONException; import org.json.JSONObject; …

12
使用片段时在Android导航抽屉图像和Up插入符之间切换
当使用导航抽屉时,Android开发人员建议在ActionBar中“仅导航抽屉中表示的那些屏幕实际上应该具有导航抽屉图像”,而“所有其他屏幕都具有传统的上克拉”。 有关详细信息,请参见此处:http: //youtu.be/F5COhlbpIbY 我正在使用一项活动来控制片段的多个级别,并且可以使Navigation Drawer图像在所有级别上显示和运行。 创建较低级别的片段时,我可以调用ActionBarDrawerToggle setDrawerIndicatorEnabled(false)来隐藏导航抽屉图像并显示Up插入符号 LowerLevelFragment lowFrag = new LowerLevelFragment(); //disable the toggle menu and show up carat theDrawerToggle.setDrawerIndicatorEnabled(false); getSupportFragmentManager().beginTransaction().replace(R.id.frag_layout, lowFrag, "lowerFrag").addToBackStack(null).commit(); 我遇到的问题是,当我导航回到Up克拉的顶层片段时,仍然显示而不是原始的Navigation Drawer图像。关于如何“刷新”顶层片段上的ActionBar以重新显示导航抽屉图像的任何建议? 解 汤姆的建议对我有用。这是我所做的: 主要活动 此活动控制应用程序中的所有片段。 在准备替换其他片段的新片段时,我setDrawerIndicatorEnabled(false)像这样设置DrawerToggle : LowerLevelFragment lowFrag = new LowerLevelFragment(); //disable the toggle menu and show up carat theDrawerToggle.setDrawerIndicatorEnabled(false); getSupportFragmentManager().beginTransaction().replace(R.id.frag_layout, lowFrag).addToBackStack(null).commit(); 接下来,在的替代中onBackPressed,我通过将DrawerToggle设置为如下来还原了上述内容setDrawerIndicatorEnabled(true): @Override …


18
插件太旧,请更新到较新版本,或将环境变量ANDROID_DAILY_OVERRIDE设置为
今天,我只是从Android SDK中导入了一个示例应用程序作为项目中的模块(分析),当我尝试对其进行同步时,突然出现了gradle错误: Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE envrinment variable to... 这是我的应用程序gradle文件: apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion "22.0.0" defaultConfig { applicationId "xxx.xxxxxx.xxxxx" versionCode 1 versionName '1' minSdkVersion 9 targetSdkVersion 22 versionCode 1 versionName '1' } buildTypes { release { …

7
SparseArray与HashMap
我可以想到几个HashMap具有整数键的SparseArrays 比s 更好的原因: 的Android文档SparseArray说“通常比传统的慢HashMap”。 如果使用HashMaps而不是SparseArrays 编写代码,则您的代码将与Map的其他实现一起使用,并且将能够使用所有为Maps设计的Java API。 如果您使用HashMap而不是SparseArrays 编写代码,则您的代码将在非Android项目中运行。 地图会覆盖equals(),hashCode()而SparseArray不会。 但是,每当我尝试HashMap在Android项目中使用带有整数键的a 时,IntelliJ都会告诉我应该使用a SparseArray代替。我觉得这真的很难理解。有谁知道使用SparseArrays的任何令人信服的理由?

13
在片段及其容器活动之间传递数据
如何在片段及其容器活动之间传递数据?是否有类似于通过意图在活动之间传递数据的东西? 我读了这篇文章,但并没有太大帮助:http : //developer.android.com/guide/topics/fundamentals/fragments.html#CommunicatingWithActivity

1
onStart()和onResume()之间的区别
我无法理解onStart()过渡状态的含义。该onResume()方法总是在after之后调用onStart()。为什么不能将onResume()after之后的方法onRestart()和onCreate()方法仅仅排除在外onStart()?目的是什么? 为什么我们不能没有生活onStart()。我仍然认为它是多余的(可能是因为无法完全理解其含义)。
176 android 

25
如何确定Android中文件的MIME类型?
假设我有完整的文件路径,例如:(/ sdcard / tlogo.png)。我想知道它的mime类型。 我为此创建了一个函数 public static String getMimeType(File file, Context context) { Uri uri = Uri.fromFile(file); ContentResolver cR = context.getContentResolver(); MimeTypeMap mime = MimeTypeMap.getSingleton(); String type = mime.getExtensionFromMimeType(cR.getType(uri)); return type; } 但是当我调用它时,它返回null。 File file = new File(filePath); String fileType=CommonFunctions.getMimeType(file, context);


23
无法解析styles.xml中的符号“主题”(Android Studio)
从今天开始,Android Studio在styles.xml中找不到AppCompat主题,但是例如代码中的AppCompatActivity确实可以识别。我的Android Studio版本是2.2.2,内部版本#AI-145.3360264 我已经尝试升级到最新的构建工具,编译sdk(25)版本等,但是它没有解决问题。 目前,我已经从sdk管理器安装了以下内容: Android API:19和23 SDK平台工具:25.0.1 SDK工具:25.2.3 构建工具:23.0.2和25.0.1 支持库:40 谷歌仓库:39 和其他一些,则不必在此处列出。 应用程序的build.gradle: apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion '25.0.1' defaultConfig { applicationId "xxx.xxxxxxxx.xxxxxxxxx" //not the real applicationId minSdkVersion 14 targetSdkVersion 19 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled true shrinkResources true …

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.