Questions tagged «android»

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

12
如何在Android中为视图设置不透明度(Alpha)
我有一个按钮,如下所示: <Button android:text="Submit" android:id="@+id/Button01" android:layout_width="fill_parent" android:layout_height="wrap_content"> </Button> 在我的onCreate()事件中,我这样呼叫Button01: setContentView(R.layout.main); View Button01 = this.findViewById(R.id.Button01); Button01.setOnClickListener(this); 应用程序中有背景,我想在此提交按钮上设置不透明度。如何为该视图设置不透明度?我可以在Java端设置它,还是可以在main.xml文件中设置它? 在Java方面,我尝试了Button01.mutate().SetAlpha(100),但它给了我一个错误。
211 android  button  view  opacity 

4
createScaledBitmap的过滤器参数做什么?
的声明android.graphics.Bitmap.createScaledBitmap是 public static Bitmap createScaledBitmap (Bitmap src, int dstWidth, int dstHeight, boolean filter) 但是,文档没有解释任何参数。除了以外,所有其他都很明显boolean filter。有人知道它做什么吗?
210 android  scaling 

12
Android Studio Google JAR文件导致GC开销限制超出错误
我在OS X上使用Android Studio。收到此错误消息: 失败:生成失败,发生异常。 出了什么问题:任务':app:preDexDebug'的执行失败。com.android.ide.common.internal.LoggedErrorException:无法运行命令:/ Applications / Android Studio.app/sdk/build-tools/android-4.4W/dx --dex --output / Users / alex / AndroidStudioProjects / SilentSMS / app / build / intermediates / pre-dexed / debug / android-4.3_r2.1-f22bbff4d1017230e169a4844a9c2195f13060d2.jar /Users/alex/AndroidStudioProjects/SilentSMS/app/libs/android-4.3_r2.1.jar 错误代码:3输出: UNEXPECTED TOP-LEVEL ERROR: java.lang.OutOfMemoryError: GC overhead limit exceeded at com.android.dx.cf.code.RopperMachine.getSources(RopperMachine.java:665) at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:288) at com.android.dx.cf.code.Simulator$SimVisitor.visitLocal(Simulator.java:612) at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:412) at …
210 java  android  overhead 


30
在viewpager中获取当前的Fragment实例
以下是我的代码,3 Fragment classes每个代码都嵌入了的3个选项卡ViewPager。我有一个菜单选项。如所示onOptionsItemSelected(),通过选择一个选项,我需要更新当前可见的片段。要进行更新,我必须调用片段类中的方法。有人可以建议如何调用该方法吗? public class MainActivity extends ActionBarActivity { ViewPager ViewPager; TabsAdapter TabsAdapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ViewPager = new ViewPager(this); ViewPager.setId(R.id.pager); setContentView(ViewPager); final ActionBar bar = getSupportActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //Attaching the Tabs to the fragment classes and setting the tab title. TabsAdapter = new TabsAdapter(this, ViewPager); TabsAdapter.addTab(bar.newTab().setText("FragmentClass1"), …

23
如何在NestedScrollView中使用RecyclerView?
RecyclerView里面怎么用NestedScrollView? RecyclerView设置适配器后,内容不可见。 UPDATE布局代码已更新。 <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="@dimen/keyline_1"> </RelativeLayout> <View android:id="@+id/separator" android:layout_width="match_parent" android:layout_height="1dp" android:background="#e5e5e5" /> <android.support.v7.widget.RecyclerView android:id="@+id/conversation" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> </android.support.v4.widget.NestedScrollView>

13
如何防止回到上一个活动?
当我在手机上按了BACK按钮时,我要防止特定活动返回到先前的活动。 具体来说,我有登录和注册屏幕,HomeScreen当发生成功的登录/注册时,两者都启动一个新的活动。启动HomeScreen后,我想防止用户能够通过按BACK键返回登录或注册屏幕。 我尝试使用Intent.FLAG_ACTIVITY_NO_HISTORY,但是由于该应用程序集成了Facebook,因此当使用“使用Facebook登录”时,Facebook应该返回到初始登录屏幕,因此我应该保留这些活动的历史记录。 我想到了在按下按钮时覆盖BACK按钮的行为HomeScreen以直接完成应用程序, @Override public void onBackPressed() { finish(); } 但这也不起作用。

16
我如何生成一个可以在不带react-native的服务器的情况下运行的apk?
我已经构建了我的应用程序,可以在本地仿真器上运行它,也可以通过更改调试服务器在同一网络中的android设备上运行它。 但是,我想构建一个可以发送给某人的APK,而无需访问开发服务器,我希望他们能够测试应用程序。 我看到文档中有一节在iOS上使用脱机捆绑包。但是我不知道如何为android实现相同的功能。这可能吗?如果是这样,怎么办? 更新:关于这个问题的答案(Android无法加载JS bundle),据说可以从开发服务器下载脱机捆绑包。但是,当我从开发服务器获取捆绑软件时,无法加载图像文件。

16
如何检索视图的尺寸?
我有一个观点TableLayout, TableRow and TextView。我希望它看起来像一个网格。我需要获取此网格的高度和宽度。这些方法getHeight()和getWidth()总是返回0。这发生在我和动态也格式化网格时我使用XML版本。 如何检索视图的尺寸? 这是我在Debug中用于检查结果的测试程序: import android.app.Activity; import android.os.Bundle; import android.widget.TableLayout; import android.widget.TextView; public class appwig extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.maindemo); //<- includes the grid called "board" int vh = 0; int vw = 0; //Test-1 used the xml layout (which is displayed …

6
单击URL将打开默认浏览器
我已经在中加载了外部URL WebView。现在我需要的是,当用户单击所加载页面上的链接时,它必须像普通浏览器一样工作,并在同一浏览器中打开该链接WebView。但是它正在打开默认浏览器并在其中加载页面吗? 我启用了JavaScript。但仍然无法正常工作。我忘记了什么吗?



13
删除动作栏下方的阴影
我使用actionbarsherlock。下面的代码段负责将其背景更改为自定义的背景。 <style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.ActionBar"> <item name="background">@drawable/actionbar_bg</item> <item name="android:background">@drawable/actionbar_bg</item> <...> </style> <style name="Theme.MyApp" parent="@style/Theme.Sherlock.Light"> <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item> <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item> <..> </style> 它适用于actionbarsherlock(在蜂窝以下的版本上)。但是在ICS中,我不希望在操作栏下方有一个阴影。使它消失的样式项是什么?

10
Android Google映射java.lang.NoClassDefFoundError:无法解决以下问题:Lorg / apache / http / ProtocolVersion
我正在使用Google Maps Android SDK 11.6.2(也尝试过15.0.1),但是在显示地图之前我遇到了崩溃。已经检查清单中的API密钥,它可用,但是仍然会发生此问题。我的目标SDk版本为28.是否导致此问题。 java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion; at el.b(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):3) at ek.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):4) at em.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):51) at com.google.maps.api.android.lib6.drd.ap.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):11) at dw.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):16) at dw.run(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):61) Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.ProtocolVersion" on path: DexPathList[[zip file "/system/priv-app/PrebuiltGmsCorePi/app_chimera/m/MapsDynamite.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/00000036/MapsDynamite.apk!/lib/armeabi-v7a, /data/user_de/0/com.google.android.gms/app_chimera/m/00000036/MapsDynamite.apk!/lib/armeabi, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:126) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at ad.loadClass(:com.google.android.gms.dynamite_dynamiteloader@12848063@12.8.48 (100408-196123505):25) at …


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.