Questions tagged «android»

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



1
导航抽屉-禁用滑动
有什么方法可以禁用滑动手势来打开导航抽屉吗?在选项卡之间滑动时出现菜单时,确实很烦人。
86 android 

6
使用Android WebView加载现有的.html文件
我确实尝试了以下示例,来自Google代码的演示以及其他资源 WebView,但是当我尝试用自己的代码进行操作时,它对我不起作用。 我想加载myfile.html我放在资产文件夹中的文件,并使用: private WebView myWebView; myWebView.loadUrl("file:///android_assets/myfile.html"); 在模拟器上显示错误 file:///android_assets/myfile.html无法加载以下位置的网页:未找到所需的文件。 /android_assets/myfile.html 当我将该文件放到文件res/raw/夹并使用时: myWebView.loadUrl("file:///android_res/raw/myfile.html"); 那么只有模拟器android 2.2 API级别8可以加载文件,其他旧版本则显示相同的错误。我想念什么吗? 有什么方法可以在适用于所有API版本的应用程序包中加载现有的.html文件吗?

10
在状态栏上半透明的导航抽屉不起作用
我正在研究Android项目,正在实现导航抽屉。我正在阅读新的《材料设计规范》和《材料设计清单》。 规范说,滑出窗格应该漂浮在包括状态栏在内的所有其他内容之上,并且在状态栏上是半透明的。 我的导航面板在状态栏上,但是没有任何透明度。我已经按照Google开发人员博客专栏中的建议,遵循了该SO帖子中的代码,该链接位于上方的链接如何使用DrawerLayout在ActionBar / Toolbar和状态栏下方显示?。 下面是我的XML布局 <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/my_drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.v7.widget.Toolbar android:id="@+id/my_awesome_toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minHeight="?attr/actionBarSize" android:background="@color/appPrimaryColour" /> </LinearLayout> <LinearLayout android:id="@+id/linearLayout" android:layout_width="304dp" android:layout_height="match_parent" android:layout_gravity="left|start" android:fitsSystemWindows="true" android:background="#ffffff"> <ListView android:id="@+id/left_drawer" android:layout_width="match_parent" android:layout_height="match_parent" android:choiceMode="singleChoice"></ListView> </LinearLayout> </android.support.v4.widget.DrawerLayout> 以下是我的应用主题 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/appPrimaryColour</item> <item name="colorPrimaryDark">@color/appPrimaryColourDark</item> <item name="colorAccent">@color/appPrimaryColour</item> <item name="windowActionBar">false</item> …

12
Android Studio始终使用> 100%CPU-似乎没有后台进程在运行
我注意到Android Studio(运行时)始终使用超过100%的CPU,即使它看起来没有IDE正在运行的后台进程(索引等)。我可能会怀疑这是我的盒子特有的,但是一些其他开发人员也遇到了这个问题。 通常,CPU使用率通常在100s或200s左右(请参见下面的屏幕截图)。有人也遇到过吗?如果是这样,IDE中是否有任何策略或选项可以纠正这种对系统资源的大量使用?

16
设置背景Drawable时,填充会去哪里?
我对我的这个问题EditText和Button意见,在这里我对他们一个很好的填充空间从文了,但是当我改变的背景,setBackgroundDrawable或者setBackgroundResource说填补处理永远失去了。
86 android 


16
以授予的INSTALL_PACKAGES权限静默安装应用
我正在尝试将apk静默安装到系统中。我的应用位于/ system / app中,并已成功授予权限“ android.permission.INSTALL_PACKAGES” 但是,我在任何地方都找不到如何使用此权限。我试图将文件复制到/ data / app,但没有成功。我也尝试使用此代码 Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType( Uri.parse("file:///sdcard/app.apk"), "application/vnd.android.package-archive"); startActivity(intent); 但是此代码将打开标准安装对话框。如何在没有root授予的情况下静默安装应用程序android.permission.INSTALL_PACKAGES? PS我正在编写一个应用程序,它将在首次启动时将许多APK从文件夹安装到系统中(替换安装向导)。我需要它来减轻固件的重量。 如果您认为我正在写病毒:所有程序都安装在/ data / app中。只能将许可Install_packages授予/ system / app中的系统级程序,或者使用系统密钥对其进行签名。因此病毒无法到达那里。 如前所述,如果http://www.mail-archive.com/android-porting@googlegroups.com/msg06281.html应用程序具有install_packages权限,则可以将其静默安装。而且,您不需要Install_packages权限即可非静默地安装软件包。加上http://www.androidzoom.com/android_applications/tools/silent-installer_wgqi.html

6
Android软键盘永远不会在模拟器中显示
我是Android新手。我已经花了两个小时进行搜索。无论我尝试使用什么软键盘,都不会为我显示EditText。我简单地创建它: EditText editText = (EditText)findViewById(R.id.editText); 我试过了: editText.requestFocus();//i tried without this line too InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); 和: editText.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); } }); 我也尝试过: getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); 我试图将这一行写入AndroidManifest.xml文件: android:windowSoftInputMode="stateVisible|adjustResize" 但都是徒劳的。它只是从不显示。我想念什么?
86 android  keyboard 

12
亚行拉多个文件
使用拉动多个文件的最佳方法是什么 adb pull 我的/sdcard/25个文件中包含以下名称: gps1.trace gps2.trace ... gps25.trace 通配符不起作用: adb pull /sdcard/gps*.trace .
86 android  adb 

4
android:attr / activatedBackgroundIndicator如何工作?
我一直在寻找在显示用于选择的上下文操作栏时如何突出显示列表中的选定项目,而我发现的解决方案是将android:background行布局xml的属性设置为"?android:attr/activatedBackgroundIndicator"。 设置该如何工作? 涉及的机制是什么? 像“?”,“ attr”,“ activatedBackgroundIndicator”这样的语法元素是什么意思? “ activatedBackgroundIndicator”的含义在哪里定义?
86 android 

7
如何从WebView获取网页内容?
在Android上,我WebView正在显示一个页面。 如何获得页面源而不再次请求页面? 似乎WebView应该有某种getPageSource()返回字符串的方法,但可惜没有。 如果启用JavaScript,则在此调用中放入适当的JavaScript以获取内容是什么? webview.loadUrl("javascript:(function() { " + "document.getElementsByTagName('body')[0].style.color = 'red'; " + "})()");

2
如何:为自定义窗口小部件定义主题(样式)项
我为控件编写了自定义窗口小部件,该控件在整个应用程序中广泛使用。小部件类ImageButton通过几种简单的方法派生并扩展它。我已经定义了一种样式,可以在使用时将其应用于小部件,但是我更愿意通过主题进行设置。在R.styleable我看到的小部件样式属性如imageButtonStyle和textViewStyle。有什么方法可以为我编写的自定义窗口小部件创建类似的东西吗?

12
ViewPager不会重新绘制内容,而是保持空白
我们在这里遇到了ViewPager的一个非常奇怪的问题。我们在每个ViewPager页面上嵌入列表,并在更新列表数据时在列表适配器和视图分页器适配器上触发notifyDataSetChanged。 我们观察到的是,有时页面不会更新其视图树,即保持空白,有时甚至在分页时消失。当来回翻动几次时,内容将突然重新出现。似乎Android在这里缺少视图更新。我还注意到,在使用层次结构查看器进行调试时,选择视图将始终使其重新出现,这显然是因为层次结构查看器会强制所选视图重新绘制自身。 但是我无法以编程方式进行这项工作;使列表视图无效,甚至使整个视图分页器无效,都无效。 这是与compatible-v4_r7库一起使用的。我还尝试使用最新的修订版,因为它声称可以解决与视图分页器有关的许多问题,但是却使事情变得更糟(例如,手势被打断了,以至于有时它不再让我翻阅所有页面。) 是否还有其他人也遇到了这些问题,或者您是否知道可能是什么原因造成的?

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.