Questions tagged «android»

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

6
API级别29中不推荐使用Environment.getExternalStorageDirectory()
在android Java上工作,最近将SDK更新到API级别29,现在显示警告,指出 Environment.getExternalStorageDirectory() 在API级别29中已弃用 我的代码是 private void saveImage() { if (requestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { final String folderPath = Environment.getExternalStorageDirectory() + "/PhotoEditors"; File folder = new File(folderPath); if (!folder.exists()) { File wallpaperDirectory = new File(folderPath); wallpaperDirectory.mkdirs(); } showLoading("Saving..."); final String filepath=folderPath + File.separator + "" + System.currentTimeMillis() + ".png"; File file = new …

13
Android对话框:删除标题栏
我有一个奇怪的行为,无法查明原因。 我的经典应用程式 requestWindowFeature(Window.FEATURE_NO_TITLE); 删除标题/状态栏。 然后,我创建一个对话框以允许用户输入信息(名称等) 使用物理键盘,没问题,但是当我使用虚拟键盘时,我有一个奇怪的行为: 每次我在虚拟键盘上按下某个键时,标题/状态栏就会重新出现,从而推动所有键盘布局消失,然后再次消失(就像启动应用程序时的动画一样) 这是一些代码: dialog = new Dialog(context); dialog.setContentView(R.layout.logindialog); dialog.setTitle("Login:"); WindowManager.LayoutParams a = dialog.getWindow().getAttributes(); // dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); a.dimAmount = 0; dialog.getWindow().setAttributes(a); dialog.setCancelable(true); dialog.getWindow().setLayout(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT); 然后 dialog.show(); 我试过了 dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 但它使我的应用程序崩溃。 这是XML <TextView android:id="@+id/LoginText" android:gravity="fill" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Login:"> </TextView> <EditText android:id="@+id/LoginEdit" android:layout_height="wrap_content" android:singleLine="true" android:text="jason" android:layout_width="200sp"/> <TextView android:id="@+id/PasswordText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Password:"> …
108 android  layout  dialog 


13
Android:更新至新版本的Gradle后,出现“清单合并失败”错误
接受将项目更新为gradle的新版本后,出现以下错误: Error:Execution failed for task ':app:processDebugManifest'. Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.0-alpha1) from [com.android.support:cardview-v7:26.0.0-alpha1] AndroidManifest.xml:24:9-38 is also present at [com.android.support:design:25.3.1] AndroidManifest.xml:27:9-31 value=(25.3.1). Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:22:5-24:41 to override. 我怎么解决这个问题?这是我的应用程序的build.gradle文件: android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "com.sample.bookReader" minSdkVersion 16 targetSdkVersion 25 versionCode 1 …
108 android 

11
Android中的垃圾收集器
我已经看到许多Android答案,建议在某些情况下调用垃圾回收器。 在执行需要大量内存的操作之前,在Android中请求垃圾收集器是一种好习惯吗?如果没有,我应该仅在遇到OutOfMemory错误时才调用它吗? 在诉诸垃圾收集器之前,我还应该使用其他东西吗?



16
以编程方式禁用ScrollView?
我想启用ScrollView并通过单击按钮禁用它。 禁用意味着ScrollView不存在..并启用它返回ScrollView。 我想要这样做是因为我有一个带有文本图像的画廊,然后单击按钮,屏幕方向会发生变化,因此在“横向”中,文本会变大。而且我希望使用ScrollView,以便图像不会自身拉伸并且文本变得不可读。 scrollview.Enabled=false / setVisibility(false) 什么都不做。 xml: <ScrollView android:id="@+id/QuranGalleryScrollView" android:layout_height="fill_parent" android:layout_width="fill_parent"> <Gallery android:id="@+id/Gallery" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="horizontal"></Gallery> </ScrollView> 谢谢 Edit1:我不能使用“可见性”,因为那样会同时隐藏Gallery,所以我想隐藏ScrollView的效果。当使用ScrollView时,“图库”中的图像将变为滚动状态,并且不适合屏幕,因此您必须滚动才能查看整个图像,我不想在单击按钮时禁用/启用该功能。 我尝试了这个: ((ScrollView)findViewById(R.id.QuranGalleryScrollView)).setOnTouchListener(null); ((ScrollView)findViewById(R.id.QuranGalleryScrollView)).setHorizontalScrollBarEnabled(false); ((ScrollView)findViewById(R.id.QuranGalleryScrollView)).setVerticalScrollBarEnabled(false); ((ScrollView)findViewById(R.id.QuranGalleryScrollView)).setEnabled(false); 但是图库中的图像仍然可以滚动并且不适合屏幕。.解决方案是什么?

6
Android:从ListView访问子视图
我需要找出使用来显示的列表中一个元素的像素位置ListView。看来我应该得到一个TextView的然后使用getTop(),但我不知道如何获取的子视图ListView。 更新:对于,子ViewGroup项与列表中的项目不一对一对应ListView。相反,ViewGroup的子项仅对应于当前可见的那些视图。因此getChildAt(),该操作基于的内部索引,ViewGroup并且不一定与所ListView使用列表中的位置有任何关系。


10
Android模拟器在哪里存储SQLite数据库?
我正在使用将数据存储在SQLite数据库中的Android应用程序。我的问题是,当您使用仿真器时,此数据库文件将存储在文件系统上的什么位置? 我已经看到它存储在 /data/data/package_name/databases 但我需要知道本地计算机的硬盘上实际映射到的位置。即使关闭了计算机,数据库也可以在模拟器的多次运行中保留,因此它不能仅驻留在RAM中。
108 android  sqlite 

9
取消执行中的AsyncTask的理想方法
我正在使用的后台线程中运行远程音频文件获取和音频文件回放操作AsyncTask。甲Cancellable进度条示出了用于提取操作的运行时间。 我想AsyncTask在用户取消(反对)操作时取消/中止运行。处理这种情况的理想方法是什么?

17
Android 4.2:具有嵌套片段的后堆栈行为
在Android 4.2中,支持库获得了对嵌套片段的支持,请参见此处。我玩过它,发现了一个关于back stack和getChildFragmentManager()的有趣行为/错误。当使用getChildFragmentManager()和addToBackStack(String name)时,通过按“后退”按钮,系统不会将后退堆栈运行到上一个片段。另一方面,当使用getFragmentManager()和addToBackStack(String name)时,通过按返回按钮,系统将返回到上一个片段。 对我来说,这种行为是意外的。通过按设备上的“后退”按钮,我希望最后一个添加到后堆栈的片段都会弹出,即使该片段是在儿童片段管理器中添加到后堆栈的。 这种行为正确吗?这是一个错误吗?有没有解决此问题的方法? getChildFragmentManager()的示例代码: public class FragmentceptionActivity extends FragmentActivity { @Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); final FrameLayout wrapper1 = new FrameLayout(this); wrapper1.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); wrapper1.setId(1); final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.topMargin = 0; final TextView text = new TextView(this); text.setLayoutParams(params); …

1
在Android中进行“应用程序设置”的最佳方法是什么?[关闭]
已关闭。这个问题需要更加集中。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅通过编辑此帖子来关注一个问题。 5年前关闭。 改善这个问题 我想为Android应用程序存储一些应用程序设置(例如API的URL和一些测试设置)。 我主要是作为.NET开发人员工作的,因此我习惯于使用此文件app.config。在Android中执行此操作的好方法是什么?
108 android 


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.