Questions tagged «android»

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

9
match_parent宽度在RecyclerView中不起作用
我的RecyclerView和项目具有match_parent宽度,但结果是: <view class="android.support.v7.widget.RecyclerView" android:layout_width="match_parent" 和项目: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" android:id="@+id/ll_itm" android:orientation="horizontal" android:layout_width="match_parent" 充分: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" android:id="@+id/ll_itm" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:weightSum="100" android:gravity="right" > <Button android:layout_width="0dp" android:layout_weight="15" android:layout_height="fill_parent" android:text="ملاحظات" android:id="@+id/button" /> <LinearLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="20" android:gravity="center" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <com.getbase.floatingactionbutton.FloatingActionButton android:layout_width="fill_parent" android:layout_height="fill_parent" fab:fab_plusIconColor="#ff56ff83" fab:fab_colorNormal="@color/d_red" …



2
ConnectionTimeout与SocketTimeout
我正在使用的库有问题。可能是图书馆,也可能是我使用错误! 基本上,当我这样做时(以​​毫秒为单位) _ignitedHttp.setConnectionTimeout(1); // v short _ignitedHttp.setSocketTimeout(60000); // 60 seconds 没有超时异常会生成,并且可以正常工作,但是,当我执行以下操作时, _ignitedHttp.setConnectionTimeout(60000); // 60 seconds _ignitedHttp.setSocketTimeout(1); // v short 我收到一个套接字异常。 所以,我的问题是为什么我不能模拟连接异常?我是否误解了套接字和连接超时之间的区别?该库在这里(尚未正式发布)。

18
如何制作较小的RatingBar?
我在布局中添加了RatingBar: <RatingBar android:id="@+id/ratingbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:numStars="5" android:stepSize="1.0" /> 但是评级栏的默认样式太大。 我试图通过添加android样式来更改它:style="?android:attr/ratingBarStyleSmall" 但是结果太小,无法使用此属性设置费率。 我该怎么办?

11
Android“无法添加窗口-令牌null不适用于应用程序”异常
尝试打开对话框时出现以下Android异常。有人可以帮我了解发生了什么,如何解决此问题? android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application at android.view.ViewRoot.setView(ViewRoot.java:509) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) at android.app.Dialog.show(Dialog.java:241)

13
从屏幕上删除/隐藏首选项
我有一个扩展PreferenceActivity的活动。我正在从xml文件加载首选项。但是在某些情况下,我需要根据我的应用程序状态从屏幕上完全隐藏首选项之一。有一个setEnabled方法,但这并不是我想要的。我想从屏幕上完全删除该首选项。可能吗 ?


11
Android OnClickListener-识别按钮
我有活动: public class Mtest extends Activity { Button b1; Button b2; public void onCreate(Bundle savedInstanceState) { ... b1 = (Button) findViewById(R.id.b1); b2 = (Button) findViewById(R.id.b2); b1.setOnClickListener(myhandler); b2.setOnClickListener(myhandler); ... } View.OnClickListener myhandler = new View.OnClickListener() { public void onClick(View v) { // MY QUESTION STARTS HERE!!! // IF b1 do this …

8
创建看起来像材料设计准则的SearchView
我目前正在学习如何将我的应用程序转换为Material design,并且现在有点卡住了。我添加了工具栏,并在导航抽屉中覆盖了所有内容。我现在正在尝试创建一个类似于材料指南中的可扩展搜索: 这是我现在所能获得的,我不知道如何像上面这样进行: 这是我的菜单xml: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_search" android:icon="@android:drawable/ic_menu_search" android:title="Search" app:showAsAction="always" app:actionViewClass="android.support.v7.widget.SearchView" /> </menu> 那行得通,我得到一个菜单项,该菜单项可以扩展到SearchView,并且可以很好地过滤列表。虽然看起来与第一张图片不一样。 我尝试使用MenuItemCompat.setOnActionExpandListener(),R.id.action_search所以可以将主页图标更改为后退箭头,但这似乎不起作用。监听器中没有任何内容。即使这样行​​得通,它也不会非常接近第一张图片。 如何在新的appcompat工具栏中创建类似于材料指南的SearchView?


6
通知通过旧的Intent Extras
我正在通过以下代码在BroadcastReceiver中创建一个通知: String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); int icon = R.drawable.ic_stat_notification; CharSequence tickerText = "New Notification"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.defaults |= Notification.DEFAULT_VIBRATE; long[] vibrate = {0,100,200,200,200,200}; notification.vibrate = vibrate; notification.flags |= Notification.FLAG_AUTO_CANCEL; CharSequence contentTitle = "Title"; CharSequence contentText = …

30
Android emulator-5554离线
我在使用模拟器-5554时遇到问题,它不断告诉我它处于脱机状态。 当我adb devices从命令行执行操作时,它说 emulator-5554 offline 即使重新启动后,我仍然尝试执行该命令,但仍显示它处于脱机状态。 问题是当我尝试abd install <path>从命令提示符下使用.apk文件将其安装到模拟器时,它告诉我它是脱机的,如果我创建另一台设备并运行该设备,然后尝试安装.apk文件,则说我连接了太多设备。换句话说,我无法安装.apk文件。 我该如何摆脱那个该死的模拟器5554?我听说如果您重新启动,它将清除所有设备,但这似乎不起作用。就像我的计算机启动时正在初始化一样。有没有人遇到这个问题? 谢谢

10
活动<应用程序名称>泄漏了最初绑定在此处的ServiceConnection <ServiceConnection名称> @ 438030a8
我正在开发我的第一个Android应用程序。我的应用程序中有三个活动,用户经常来回切换。我还拥有一个处理telnet连接的远程服务。这些应用程序需要绑定到此服务才能发送/接收telnet消息。 编辑 谢谢BDLS为您提供丰富的答案。根据您对bindService()用作独立功能或after之后的区别的澄清,我已经重新编写了代码,startService()现在当使用后退按钮在活动之间循环时,我只会间歇性地收到泄漏错误消息。 我的连接活动具有以下onCreate()和onDestroy(): /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* * Initialize the ServiceConnection. Note that this is the only place startService() is run. * It is also the only time bindService is run without dependency on connectStatus. */ …

7
华为手机上的“受保护的应用”设置及其处理方式
我有一个用于Android 5.0的Huawei P8,用于测试应用程序。该应用程序需要在后台运行,因为它会跟踪BLE区域。 我发现华为内置了一个称为“受保护的应用程序”的“功能”,可以通过电话设置(电池管理器&gt;受保护的应用程序)进行访问。这样一来,关闭屏幕后,选定的应用程序即可继续运行。 对华为来说明智,但对我来说不幸的是,它看起来像是选择加入的,即默认情况下应用已退出,而您必须手动将其放入。这不是热门产品,因为我可以在常见问题解答中为用户提供建议或打印有关此修复程序的文档,但我最近安装了Tinder(出于研究目的!),并注意到该文件已自动放入受保护列表中。 有谁知道我该如何为我的应用程序做到这一点?清单中是否有设置?这是华为因其受欢迎的应用程序而为Tinder启用的功能吗?

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.