Questions tagged «android»

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


16
BottomSheetDialogFragment的圆角
我有一个自定义的BttomSheetDialogFragment,我想在底部视图的顶部有圆角 这是我的自定义类,它使我想要从底部显示的布局膨胀 View mView; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mView = inflater.inflate(R.layout.charge_layout, container, false); initChargeLayoutViews(); return mView; } 而且我也有这个xml资源文件作为背景: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android:topRightRadius="35dp" android:topLeftRadius="35dp" /> <solid android:color="@color/white"/> <padding android:top="10dp" android:bottom="10dp" android:right="16dp" android:left="16dp"/> 但是问题是,当我将此资源文件设置为布局的根元素的背景时,拐角仍未圆化 而且我不能使用下面的代码: this.getDialog().getWindow().setBackgroundDrawableResource(R.drawable.charge_layout_background); 因为它覆盖了BottomSheetDialog的默认背景,并且在我的Bottom View上方没有任何半透明的灰色


4
Android中项目上的自定义ListView点击问题
所以我有一个自定义的ListView对象。列表项具有两个彼此堆叠的文本视图,以及一个水平进度条,在我实际执行操作之前,我一直希望保持水平状态。最右边是一个复选框,仅在用户需要将更新下载到其数据库时才显示。通过将可见性设置为Visibility.GONE禁用复选框时,我可以单击列表项。当复选框可见时,我无法单击列表中除复选框以外的任何内容。我已经进行了一些搜索,但没有找到与我目前的情况有关的任何内容。我发现了这个问题但由于使用ArrayLists内部包含数据库列表,因此我使用了重写的ArrayAdapter。我是否只需要获取LinearLayout视图并像Tom一样添加onClickListener?我不确定。 这是listview行布局XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="6dip"> <LinearLayout android:orientation="vertical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_parent"> <TextView android:id="@+id/UpdateNameText" android:layout_width="wrap_content" android:layout_height="0dip" android:layout_weight="1" android:textSize="18sp" android:gravity="center_vertical" /> <TextView android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:id="@+id/UpdateStatusText" android:singleLine="true" android:ellipsize="marquee" /> <ProgressBar android:id="@+id/UpdateProgress" android:layout_width="fill_parent" android:layout_height="wrap_content" android:indeterminateOnly="false" android:progressDrawable="@android:drawable/progress_horizontal" android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal" android:minHeight="10dip" android:maxHeight="10dip" /> </LinearLayout> <CheckBox android:text="" android:id="@+id/UpdateCheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> 这是扩展ListActivity的类。显然它仍在开发中,因此可以原谅遗漏或遗留的东西: …

10
Android中的垂直(旋转)标签
我需要两种在Android中显示垂直标签的方法: 水平标签逆时针旋转90度(侧面字母) 带有一个字母在另一个字母下方的水平标签(例如商店标志) 我是否需要针对两种情况(一种情况)开发自定义小部件,是否可以使TextView以这种方式呈现,并且如果我需要完全自定义,那么做这样的事情的好方法是什么?

4
adb更新非市场apk?
有什么方法可以更新(而不是重新安装)Android设备上的非市场apk?我只能找到adb安装(与adb update一样)
110 android  adb 

6
从Android中的事件处理方法返回的布尔值的含义是什么
在android中,大多数事件侦听器方法都返回布尔值。正确/错误值是什么意思?这将导致子序列事件吗? class MyTouchListener implements OnTouchListener { @Override public boolean onTouch(View v, MotionEvent event) { logView.showEvent(event); return true; } } 对于上面的示例,如果在onTouch方法中返回true ,我发现根据我的logView捕获了每个触摸事件(DOWN,UP,MOVE等)。相反,如果返回false,则首先捕获DOWN事件。因此,似乎return false将阻止事件传播。我对么 ? 此外,在OnGestureListener中,许多方法也必须返回布尔值。它们具有相同的含义吗?


11
ADT何时将BuildConfig.DEBUG设置为false?
在最新版本的ADT(r17)中,添加了一个生成的常量,BuildConfig.DEBUG该常量根据构建类型进行设置。我的问题是,它永远不会设置为false,我希望在执行“ Android Tools-> Export Signed Application Package”时会更改它,但它不适用于我。 那么,如何更改构建类型? 添加了一项功能,使您只能在调试模式下运行某些代码。现在,生成会生成一个名为BuildConfig的类,其中包含一个DEBUG常量,该常量会根据您的生成类型自动设置。您可以在代码中检查(BuildConfig.DEBUG)常量以运行仅调试功能
110 android  eclipse  adt 

4
如何为Android开发软键盘?[关闭]
已关闭。这个问题需要更加集中。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅通过编辑此帖子来关注一个问题。 5年前关闭。 改善这个问题 我想尝试一些想法,并为Android开发一种软​​键盘来替代默认键盘。 那里有关于Android软键盘开发的一般信息吗?有最佳做法或指南吗? 我可以使用键盘应用程序完成几乎所有普通Android应用程序可以做的事情吗? 我可以进行HTTP连接以将键盘数据与云数据库和其他拥有的手机同步吗? 是否可以通过按键打开其他窗口/屏幕,例如显示与常规QWERTY不同的自定义输入界面。如果那不起作用,我可以改用弹出对话框吗?
110 android  keyboard 


13
将选项卡与ViewPager一起使用时出现错误“ Java.lang.IllegalStateException活动已被破坏”
我有一个应用程序,其中包含在选项卡模式下使用ActionBarSherlock的应用程序。我有5个选项卡,每个选项卡的内容都是使用片段处理的。但是对于tab2,我有一个片段,该片段的xml文件包含一个ViewPager元素,而该元素又具有一些片段页面。最初启动应用程序时,我可以在选项卡之间进行切换,但是第二次按tab2时,出现上述错误。主要活动如下: public class MainActivity extends SherlockFragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ActionBar actionBar = getSupportActionBar(); ActionBar.Tab tab1 = actionBar.newTab().setText("Tab1"); ActionBar.Tab tab3 = actionBar.newTab().setText("Tab3"); ActionBar.Tab tab2 = actionBar.newTab().setText("Tab2"); ActionBar.Tab tab4 = actionBar.newTab().setText("Tab4"); ActionBar.Tab tab5 = actionBar.newTab().setText("Tab5"); Fragment fragment1 = new Tab1(); Fragment fragment3 = new Tab3(); Fragment …

12
RecyclerView GridLayoutManager:如何自动检测跨度计数?
使用新的GridLayoutManager:https : //developer.android.com/reference/android/support/v7/widget/GridLayoutManager.html 它需要一个显式的跨度计数,所以现在的问题就变成了:您如何知道每行有多少个“跨度”?毕竟,这是一个网格。根据测量的宽度,应该有尽可能多的RecyclerView跨度。 使用old GridView,您只需设置“ columnWidth”属性,它将自动检测可容纳多少列。这基本上是我要为RecyclerView复制的内容: 在上添加OnLayoutChangeListener RecyclerView 在此回调中,为单个“网格项”充气并对其进行度量 spanCount = recyclerViewWidth / singleItemWidth; 这似乎是很常见的行为,所以有没有我看不到的更简单方法?

4
如何模仿Google Maps的底页3个阶段的行为?
背景 我被指派制作一个行为类似于Google Maps显示找到结果底部的UI。 它具有三个不同的阶段: 底部内容。上方区域仍可触摸,底部不会滚动任何内容 全屏内容,而上部区域具有较大的标题。 全屏内容,而上方区域只有工具栏。 这就是我在Google Maps上谈论的内容: 问题 事实是,底层表还不是设计库的一部分(尽管在这里是要求的)。 不仅如此,UI似乎也很复杂,需要在多个阶段处理工具栏。 我尝试过的 我已经找到了一个很好的(足够的)底纸库(在此处),并向其片段样本中添加了内容,使其具有与材料设计样本中所示的大致相同的视图(例如此处),并具有一个CollapsingToolbarLayout来处理阶段2 + 3。 在我制作的应用程序中,我还必须在滚动时移动图标,但是我认为,如果我成功完成了其余工作,这应该很容易。这是代码: fragment_my.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout android:id="@+id/main_content" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="@dimen/detail_backdrop_height" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" app:contentScrim="?attr/colorPrimary" app:expandedTitleMarginEnd="64dp" app:expandedTitleMarginStart="48dp" app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> <ImageView android:id="@+id/backdrop" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" app:layout_collapseMode="parallax"/> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" …

14
重新加载时刷新片段
在android应用程序中,我正在将数据从Db加载到的TableView内部Fragment。但是,当我重新加载Fragment它时,它将显示以前的数据。我可以Fragment用当前数据代替以前的数据来重新填充吗?

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.