Questions tagged «android»

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

4
获取ViewPager的当前位置
我知道使用Gallery小部件可以使用getSelectedItemPosition();。检索当前位置,但是ViewPager似乎没有。 我知道我可以设置一个侦听器并在切换页面时检索位置。但是我想要当前的视图位置。

8
如何获取Android版ViewPager的当前页码?
我想知道的当前页面位置ViewPager。我创建一个适配器并将该适配器设置为ViewPager。现在,我想知道当前页码或当前视图的位置,因为我想在该特定页面上启动一些其他事件。 我用来viewPager.setCurrentItem(1);设置第一项。 是否有类似的方法来获取当前页面?

17
更改Google Maps API的“我的位置”按钮的位置
我正在使用Google Maps Android API v2,我需要一种方法来确定“我的位置”按钮的位置。 我得到这样的“我的位置”按钮: GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); final GoogleMap map = ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map)).getMap(); // This gets the button map.setMyLocationEnabled(true);

18
Ubuntu-错误:无法创建SD卡
我看到很多关于写入SD卡的帖子,但是我相信我的问题有所不同。在建立AVD的过程中,我无法创建SD卡。 我最初尝试使用Android SDK和AVD Manager来执行此操作,选择 名称:my_avd 目标:Android 2.2-API级别8 SD卡:大小:1024 MiB 皮肤:内置:默认(HVGA) 硬件:属性:抽象的LCD密度,值:160 这会弹出一个窗口,显示以下消息: “创建AVD'my_avd'的结果: 错误:无法创建SD卡。” 我试图从命令行重复该过程,收到一个类似的错误: alex@alex-desktop:~$ android create avd -n my_avd -t 1 -c 1024M Android 2.2 is a basic Android platform. Do you wish to create a custom hardware profile [no]no Error: Failed to create the SD card. 尝试遵循有关使用mksdcard的说明同样没有效果;我认为我基本缺乏linux经验可能​​会在这里引起我一个问题。当我尝试使用mksdcard时,它只是报告它找不到文件或目录。是否可以在Linux中以这种方式使用mksdcard工具? …
84 android  linux  ubuntu 

8
Android布局权重
我是Android开发的新手,我对在线性布局中设置权重有疑问。 我试图用两个自定义按钮和一个自定义编辑文本创建一行。编辑文本应仅占用其内容所需要的空间,并且两个按钮应水平扩展以填充该行中其余的可用空间。像这样... | [#Button++#] [#Button--#] [et] | 经过几次尝试,即使看起来过于复杂,这也是我能最接近我想要的东西。 | [Button] [Button] [###ET###] | <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal|center_vertical" android:layout_weight="1" > <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_horizontal|center_vertical" > <RelativeLayout android:id="@+id/btn_plus_container" android:layout_width="fill_parent" android:layout_height="wrap_content" > <ImageButton android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/btn_plus" android:background="@drawable/btn" android:layout_centerInParent="true" ></ImageButton> <TextView android:textColor="#FAFAF4" android:id="@+id/tv_dice_plus" android:text="@string/tv_plus" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" ></TextView> </RelativeLayout> </LinearLayout> <LinearLayout …
84 android  layout 

7
如何将库导出到Android Studio中的Jar?
我已经下载了一些库资源,并希望使用Android Studio将其导出为Jar文件。有没有一种方法可以使用Android Studio导出到jar文件? 编辑: 我想导出为jar的库是一个Android库。它称为“ StandOut”,可以从GitHub下载。 https://github.com/pingpongboss/StandOut

2
前台服务被Android杀死
更新:我还没有找到解决该问题的真正方法。我想出的是一种在连接断开时自动重新连接到以前的蓝牙设备的方法。这不是理想的方法,但是看起来效果很好。我很乐意听到关于此的更多建议。 我遇到的问题与这个问题大致相同:按住唤醒锁并调用包括设备(Asus Transformer)的startForeground之后,服务被终止,服务停止之前的时间(30-45分钟),使用唤醒锁,startForeground()的使用以及在屏幕关闭时打开应用程序都不会发生此问题。 我的应用程序维持与另一台设备的蓝牙连接,并在两者之间发送数据,因此它必须始终处于活动状态以侦听数据。用户可以随意启动和停止服务,实际上,这是我实现的启动或停止服务的唯一方式。服务重新启动后,与其他设备的蓝牙连接将丢失。 根据链接的问题的答案,startForeground()“减少了服务被杀死的可能性,但并没有阻止它”。我知道情况确实如此,但是我已经看到许多其他应用程序的示例,这些应用程序都没有此问题(例如Tasker)。 如果没有运行该服务直到用户停止该服务的能力,我的应用程序的实用性将大大降低。有什么办法可以避免这种情况??? 每当服务停止时,我都会在logcat中看到此消息: ActivityManager: No longer want com.howettl.textab (pid 32321): hidden #16 WindowManager: WIN DEATH: Window{40e2d968 com.howettl.textab/com.howettl.textab.TexTab paused=false ActivityManager: Scheduling restart of crashed service com.howettl.textab/.TexTabService in 5000ms 编辑:我还应该注意,这似乎不在我连接到的其他设备上发生:运行Cyanogen的HTC Legend 编辑:这是输出adb shell dumpsys activity services: * ServiceRecord{40f632e8 com.howettl.textab/.TexTabService} intent={cmp=com.howettl.textab/.TexTabService} packageName=com.howettl.textab processName=com.howettl.textab baseDir=/data/app/com.howettl.textab-1.apk resDir=/data/app/com.howettl.textab-1.apk dataDir=/data/data/com.howettl.textab app=ProcessRecord{40bb0098 2995:com.howettl.textab/10104} isForeground=true …

8
Android:如何在中心点上旋转位图
我一直在寻找解决此问题的解决方案,但无济于事,甚至没有找到答案。文档也没有解释任何东西。 我只是试图使旋转方向朝另一个对象的方向。问题在于位图不是围绕固定点旋转,而是围绕位图(0,0)旋转。 这是我遇到麻烦的代码: Matrix mtx = new Matrix(); mtx.reset(); mtx.preTranslate(-centerX, -centerY); mtx.setRotate((float)direction, -centerX, -centerY); mtx.postTranslate(pivotX, pivotY); Bitmap rotatedBMP = Bitmap.createBitmap(bitmap, 0, 0, spriteWidth, spriteHeight, mtx, true); this.bitmap = rotatedBMP; 奇怪的是,无论如何更改pre/中的值postTranslate()以及中的float参数,都没有关系setRotation()。有人可以帮忙,把我推向正确的方向吗?:)


3
在我的情况下,如何以编程方式在另一个布局之上显示一个布局?
我的主布局main.xml仅包含两个LinearLayouts: 第1LinearLayout主机一VideoView和Button, 第二个LinearLayout托管一个EditText,并且LinearLayout已将可见性值设置为“ GONE ”(android:visibility="gone") 如下所示: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/first_ll" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <VideoView android:id="@+id/my_video" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="9" /> <Button android:id="@+id/my_btn" android:layout_width="30dip" android:layout_height="30dip" android:layout_gravity="right|bottom" android:layout_weight="1" /> </LinearLayout> <LinearLayout android:id="@+id/second_ll" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingTop="2dip" android:visibility="gone" > <EditText android:id="@+id/edit_text_field" android:layout_height="40dip" android:layout_width="fill_parent" android:layout_weight="5" android:layout_gravity="center_vertical" /> </LinearLayout> </LinearLayout> 我成功实现了以下功能:Button按下(ID为my_btn时),将显示第二个 LinearLayoutwithEditText字段,并带有以下Java代码: …

13
谷歌地图API的替代品
关闭。此问题不符合堆栈溢出准则。它当前不接受答案。 想改善这个问题吗?更新问题,使其成为Stack Overflow的主题。 6年前关闭。 已锁定。该问题及其答案被锁定,因为该问题是题外话,但具有历史意义。它目前不接受新的答案或互动。 Google Maps API非常适合开发基于位置的手机服务。但是由于某些原因,在一个特殊项目中对我的使用受到限制。 例如,如果您的项目与google的一般条款冲突,则不建议使用google maps API。 在我的Android和iOS应用中,我想通过检索GPS信息在地图上显示位置。总体而言,该API应该提供与Google Maps API类似的操作范围。 您知道哪些替代品?也许有开源API?还有其他建议吗?

11
返回按钮和刷新先前的活动
如果我们有两个活动: 文件列表和上次修改时间 文件编辑活动 用户从列表中选择一个文件,然后转到文件编辑活动。完成编辑后,用户按下后退按钮以返回文件列表。 该列表未重新加载,因此对于刚编辑的文件修改时间,显示的值不正确。 按下后退按钮后导致文件列表刷新的正确方法是什么? 本示例假定不使用数据库,仅使用ArrayAdapter。
84 android 


3
Android singleTask或singleInstance启动模式?[关闭]
已关闭。这个问题是基于观点的。它当前不接受答案。 1年前关闭。 已锁定。该问题及其答案被锁定,因为该问题是题外话,但具有历史意义。它目前不接受新的答案或互动。 我有一个以列表为主要活动的应用程序,然后您可以单击项目,以打开该项目的详细视图。我也有一个与主要活动类似的搜索活动,并且按预期工作。 但是,我希望此搜索活动在堆栈中只有一个实例,以便用户可以搜索多次,然后单击“返回”将使它们返回到开始搜索之前所处的先前视图(而不是返回先前的搜索结果) singleTask和singelInstance启动模式似乎都可以执行我想要的操作,因此我不确定应为此使用哪一个,为什么?

4
如何为View.setVisibility(GONE)设置动画
我想做一个Animation当View它的可见性设置为GONE。不仅仅是消失,而是View应该“崩溃”。我用a尝试了一下,ScaleAnimation但随后是Viewis折叠,但是布局只会在Animation停止(或开始)之后(或之前)调整其空间的大小。 如何制作Animation动画,使小号Views保持在内容的正下方,而不是留有空白?

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.