Questions tagged «android»

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

7
onCheckedChanged自动调用
我从recyclerview中有一个开关,并且从DB检索数据后数据显示在recyclerview中。打开recyclerview时,我读取了DB,并且如果DB中的字段为“ Y”,则启用该开关,否则将禁用该开关。现在问题随之而来,也调用了onCheckedchanged侦听器,我希望仅当用户手动设置开关时才调用onCheckedChanged。 在打开下面的recyclerview时执行: holder.enabledisable.setChecked(messengerRecord.get_is_valid().equalsIgnoreCase("Y")); ViewHolder类: public class viewHolder extends RecyclerView.ViewHolder implements CompoundButton.OnCheckedChangeListener{ public SwitchCompat enabledisable; public viewHolder(View v) { enabledisable = (SwitchCompat) v.findViewById(R.id.enabledisable); enabledisable.setOnCheckedChangeListener(this); ................................... ................................... 刚打开recyclerView时调用的OncheckedChanged方法: @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Log.v("ranjith","called oncheckedchanged"); MessengerRecord rec; rec = dbHelper.getRecord(descview.getText().toString()); switch (buttonView.getId()) { case R.id.enabledisable: if (isChecked) { …

13
无法解决:IntelliJ Idea中带有gradle的com.google.android.gms:play-services
我正在尝试在IntelliJ Idea中将Google Play服务添加到我的libGDX项目中。我在这里遵循了安装指南:https : //developers.google.com/android/guides/setup 看起来很简单。我只是在相应部分的build.gradle中添加了这些行,所以现在看起来像: project(":android") { apply plugin: "android" apply plugin: 'com.android.application' configurations { natives } dependencies { compile project(":core") compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64" compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86" compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a" …


9
PagerAdapter的起始位置
我正在使用以下示例隐含我的viewPager:http : //code.google.com/p/viewpagerexample/issues/list 此示例的问题是我无法弄清楚如何设置起始位置,默认起始位置为0。基本上,我将无法控制左侧或右侧是否有可用视图。 有什么方法可以控制中心的“查看当前位置”?有更好的方法吗?有可能使其成为圆形吗?

18
从Glide库的缓存中删除图像
我在一个项目中使用Glide来显示文件中的图像。 下面是我的代码如何显示图像: Glide.with(DemoActivity.this) .load(Uri.parse("file://" + imagePath)) .into(mImage); 此位置(imagePath)上的图像不断变化。默认情况下,Glide缓存它在中显示的图像ImageView。因此,Glide正在为该位置的新图像显示缓存中的第一张图像。 如果我在imagePath其他位置使用相同名称的其他图像来更改图像,则Glide将显示第一个图像而不是新的图像。 两个查询是: 是否可以始终从文件中获取图像而不缓存?这样就可以解决问题。 是否有可能在获取新替换的图像之前从缓存中清除图像?这也将解决问题。

7
如何获得我的活动上下文?
我并没有真正理解整个事情是如何工作的,因此,如果我有一些A需要B扩展的类的上下文的类,Activity我如何获得该上下文? 我正在寻找一种比将上下文作为类A构造函数的参数更有效的方法。例如,如果类A将具有数百万个实例,那么我们最终将具有数以百万计的冗余指针,Context而我们应该能够以某种方式仅在某个地方放置一个getter函数。

10
如何检查Android中的单选按钮中是否选中了单选按钮?
我需要设置验证,用户必须填写/选择页面中的所有详细信息。如果有任何字段为空,想要显示Toast message to fill.现在我需要RadioButton在RadioGroup.我尝试此代码中进行设置验证,但无法正常工作。建议我正确的方法。谢谢。 // get selected radio button from radioGroup int selectedId = gender.getCheckedRadioButtonId(); // find the radiobutton by returned id selectedRadioButton = (RadioButton)findViewById(selectedId); // do what you want with radioButtonText (save it to database in your case) radioButtonText = selectedRadioButton.getText().toString(); if(radioButtonText.matches("")) { Toast.makeText(getApplicationContext(), "Please select Gender", Toast.LENGTH_SHORT).show(); Log.d("QAOD", …


26
Android INSTALL_FAILED_UID_CHANGED
我一直在使用Nexus 4在Android上进行调试,但是最近在这里遇到了此错误。在研究了此错误之后,似乎是应用程序未正确删除的问题。我正在调试的应用程序可以在其他Android设备以及仿真器上正常运行,此错误仅在Nexus 4上出现。我将设备插入计算机,并尝试删除数据/数据文件夹,但仍然可以同样的问题。我还检查了settings-apps来检查它是否确实已卸载。 有谁知道如何解决这个问题?根据一些用户的说法,我需要root访问权限才能正确删除数据/数据,这是真的吗?还是有其他解决方法?
75 android 


9
WebView中的内存泄漏
我有一个使用嵌入WebView的xml布局进行的活动。我根本没有在活动代码中使用WebView,它所做的只是坐在xml布局中并且可见。 现在,当我完成活动时,我发现我的活动没有从内存中清除。(我通过hprof转储检查)。但是,如果我从xml布局中删除WebView,则该活动将完全清除。 我已经尝试过 webView.destroy(); webView = null; 在我活动的onDestroy()中,但这没有太大帮助。 在我的hprof转储中,我的活动(名为“浏览器”)具有以下剩余的GC根(调用后destroy()): com.myapp.android.activity.browser.Browser - mContext of android.webkit.JWebCoreJavaBridge - sJavaBridge of android.webkit.BrowserFrame [Class] - mContext of android.webkit.PluginManager - mInstance of android.webkit.PluginManager [Class] 我发现其他开发人员也经历过类似的事情,请参见Filipe Abrantes的回复:http ://www.curious-creature.org/2008/12/18/avoid-memory-leaks-on-android/ 确实是一个非常有趣的帖子。最近,我很难对Android应用程序中的内存泄漏进行故障排除。最后,事实证明,我的xml布局包含一个WebView组件,即使不使用它,也阻止了屏幕旋转/应用重启后对内存进行g收集……这是当前实现的错误,还是存在某些问题使用WebView时需要做的特定工作 现在,很遗憾,博客或邮件列表上尚未收到有关此问题的答复。因此,我想知道是SDK中的错误(可能类似于http://code.google.com/p/android/issues/detail?id=2181报告的MapView错误)还是如何完全获取活动嵌入了Webview的内存?

6
如何将图像存储为Sqlite中的Blob和如何检索它?
我想将图像(来自URL)存储到sqlite数据库中。 为此,我使用: db = new DataBase(getApplicationContext()); URL url = new URL("http://sree.cc/wp-content/uploads/schogini_team.png"); URLConnection ucon = url.openConnection(); InputStream is = ucon.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is,128); ByteArrayBuffer barb= new ByteArrayBuffer(128); int current = 0; while ((current = bis.read()) != -1) { barb.append((byte) current); } ContentValues filedata= new ContentValues(); filedata.put(DataBase.IMG_SRC,barb.toByteArray()); db.insert(DataBase.Table_Img, null, filedata); …
75 android  image  blob 

5
如何为Android开发设置Vim?
谁能为Android开发描述一个好的Vim设置?我现在正在使用Eclipse,但我真的很想使用Vim,因为它速度更快,而且我更喜欢。例如,我对Eclim不感兴趣。 我对使用什么Vim插件(用于Java,自动完成等),.vimrc外观和构建/运行应用程序的整个过程(尽可能高效)的工作感兴趣。
75 android  vim 


3
通过Android WebView从JavaScript调用Java函数
我想在我的Android应用程序中对某些Java代码进行同步调用。 我正在使用此解决方案:https : //stackoverflow.com/a/3338656 我的Java代码: final class MyWebChromeClient extends WebChromeClient { public boolean onJsAlert(WebView view, String url, String message, JsResult result) { Log.d("LogTag", message); result.confirm(); return true; } } 我的JavaScript代码: <html> <script> function java_request(){ alert('test'); } </script> <body> <h2>Welcome</h2> <div id="area"></div> <form> <input type="button" value="java_call" onclick="java_request()"> </form> </body> </html> 当我点击java_call按钮时,按钮进入按下状态。我可以'test'在控制台日志中看到。一切正常,直到这里。 …

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.