Questions tagged «android»

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

4
Android:桌面上的ADB拉文件
尝试将文件从设备复制到桌面,这是一个命令: adb pull sdcard/log.txt Users/admin/Desktop 但是此命令在adb所在的platform-tools文件夹中创建了一个Users / admin / Desktop文件夹。如何将文件拉到我的桌面?
92 android  adb 

6
带有图标和文字的Android按钮
我的应用程序中有一些这样的按钮: <Button android:id="@+id/bSearch" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="16dp" android:text="Search" android:textSize="24sp" /> 我正在尝试使用文本和图标创建相同的按钮。android:drawableLeft对我不起作用(也许可以,但是我不知道如何为图标设置最大高度)。 所以我创建了一个带有ImageView和TextView的LinearLayout并使其像按钮一样工作: <LinearLayout android:id="@+id/bSearch2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:drawable/btn_default" android:clickable="true" android:padding="16dp" android:orientation="horizontal" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="5dp" android:adjustViewBounds="true" android:maxHeight="30dp" android:maxWidth="30dp" android:scaleType="fitCenter" android:src="@drawable/search_icon" /> <TextView android:id="@+id/tvSearchCaption" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:textSize="24sp" android:paddingRight="30dp" android:gravity="center" android:text="Search" /> </LinearLayout> 我的新按钮正是我想要的(字体大小,图标和文本位置)。但这看起来不像我的默认按钮: 因此,我尝试更改新按钮的背景和文本颜色: Button Search = (Button) findViewById(R.id.bSearch); LinearLayout …

5
Kotlin支持场有什么用?
作为Java开发人员,后备字段的概念对我来说有点陌生。鉴于: class Sample { var counter = 0 // the initializer value is written directly to the backing field set(value) { if (value >= 0) field = value } } 这个支持领域有什么好处?Kotlin文档说: Kotlin中的类不能具有字段。但是,有时使用自定义访问器时必须有一个后备字段。 为什么?在setter中使用属性名称本身有什么区别,例如* class Sample { var counter = 0 set(value) { if (value >= 0) this.counter = value // …

8
“没有缓存版本……可用于脱机模式。”
在Android Studio中构建新的Hello World项目时收到错误消息: FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'MyApplication2'. > Could not resolve all dependencies for configuration ':classpath'. > Could not resolve com.android.tools.build:gradle:0.9.1. Required by: :MyApplication2:unspecified > No cached version of com.android.tools.build:gradle:0.9.1 available for offline mode. BUILD FAILED Android …

5
填充不会影响XML布局中的<shape>
我正在尝试&lt;shape&gt;在XML文件/布局内的声明中设置填充。但是无论我设置了什么,都没有与填充相关的更改。如果修改任何其他属性,则会在UI上看到效果。但这不适用于填充。您能否建议可能发生这种情况的原因? 这是我要设置样式的XML Shape: &lt;shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"&gt; &lt;stroke android:width="1dp" android:color="#ffffff" android:dashWidth="2dp"/&gt; &lt;solid android:color="@color/button_white_cover"/&gt; &lt;corners android:radius="11dp"/&gt; &lt;padding android:left="1dp" android:top="20dp" android:right="20dp" android:bottom="2dp"/&gt; &lt;/shape&gt;

6
如何为Android应用程序生成QR码?[关闭]
关闭。此问题不符合堆栈溢出准则。它当前不接受答案。 想改善这个问题吗?更新问题,这样成为Stack Overflow的主题。 4年前关闭。 改善这个问题 我需要在android应用程序中创建一个qrcode,并且需要一个库或源代码,以便我可以在Android应用程序中创建QR Code。 我需要的图书馆必须: 不留下水印(如onbarcode图书馆) 不使用网络服务API创建qrcode(例如Google的zxing库) 不需要第三方安装程序(例如QR Droid) 我已经为iPhone(Objective-C)创建了这样的代码,但我需要针对Android的快速修复,直到有时间自己制作一个QR代码生成器。这是我的第一个android项目,因此任何帮助将不胜感激。
92 java  android  qr-code 

4
使用参数进行改造和GET
我正在尝试使用Retrofit向Google GeoCode API发送请求。服务界面如下所示: public interface FooService { @GET("/maps/api/geocode/json?address={zipcode}&amp;sensor=false") void getPositionByZip(@Path("zipcode") int zipcode, Callback&lt;String&gt; cb); } 当我致电服务时: OkHttpClient okHttpClient = new OkHttpClient(); RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(Constants.GOOGLE_GEOCODE_URL).setClient(new OkClient(okHttpClient)).build(); FooService service = restAdapter.create(FooService.class); service.getPositionByZip(zipCode, new Callback&lt;String&gt;() { @Override public void success(String jsonResponse, Response response) { ... } @Override public void failure(RetrofitError retrofitError) …
92 android  get  retrofit 

7
使用ItemTouchHelper.SimpleCallback禁用在RecyclerView中的位置滑动
我正在使用recyclerview 22.2.0和帮助程序类ItemTouchHelper.SimpleCallback启用对列表的滑动到关闭选项。但是,由于上面有一种标头,因此需要禁用适配器第一个位置的滑动行为。由于RecyclerView.Adapter没有isEnabled()方法,因此我尝试通过ViewHolder创建本身中的isEnabled()和isFocusable()方法禁用视图交互,但是没有成功。我试图将滑动阈值调整为一个完整值,例如SimpleCallback的方法getSwipeThreshold()中的0f或1f,但也没有成功。 我的代码的一些片段可以帮助您帮助我。 我的活动: @Override protected void onCreate(Bundle bundle) { //... initialization ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) { @Override public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { return false; } @Override public float getSwipeThreshold(RecyclerView.ViewHolder viewHolder) { if (viewHolder instanceof CartAdapter.MyViewHolder) return 1f; return super.getSwipeThreshold(viewHolder); } @Override …

29
如何以编程方式退出Android应用程序?
我确信已经读过几次这个问题了。我的客户希望我在他的应用程序中放置一个按钮,用户可以单击并退出。我已经读过这篇文章,发现打电话finish()可以做到。但是,完成只是关闭当前正在运行的活动吗?我有很多活动,因此在这种情况下,我必须传递每个活动的实例并完成它们,或将每个活动设置为Singleton模式。 我还知道Activity.moveTaskToBack(true)可以带您进入主屏幕。好的,这不是关闭,而是后台进程。那么这有效吗? 我应使用哪种方法完全关闭应用程序?上述任何方法或上述方法的任何其他方法/其他用法?

8
亚行外壳苏工作,但亚行根不
我将解锁的Galaxy S3(SGH-T999)植根 现在,我尝试adb root从Windows命令提示符运行,但是,我遇到了adbd cannot run as root in production builds错误。因此,我检查的第一件事是手机是否真的植根了? 所以我尝试了以下方法: 打开命令提示符 $adb devices // lists my device $adb shell //goes to shell $su // opens a 'SuperSu' prompt on my phone and I 'Grant' permission # // Before following the rooting instructions, I was getting 'no su command …
92 android  shell  adb  root 


3
“缺少autofillHints属性”
我有一个问题,Palette -&gt; Text 当我想设置一些视图时,收到消息问题有"Missing autofillHints attribute" 什么建议吗?
92 android 

14
将BottomSheetDialogFragment的状态设置为展开
如何使用Android支持设计库(v23.2.1)设置扩展BottomSheetDialogFragment为扩展的片段的状态BottomSheetBehavior#setState(STATE_EXPANDED)? https://code.google.com/p/android/issues/detail?id=202396说: 首先将底页设置为STATE_COLLAPSED。如果要扩展它,请调用BottomSheetBehavior#setState(STATE_EXPANDED)。请注意,您不能在视图布局之前调用该方法。 该建议的做法需要将第一膨胀的观点,但我不知道我怎么会设置BottomSheetBehaviour到片段(BottomSheetDialogFragment)。 View bottomSheet = coordinatorLayout.findViewById(R.id.bottom_sheet); BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);

9
如何检查片段中的权限
我想检查片段中的权限。 我的代码: // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), android.Manifest.permission.ACCESS_FINE_LOCATION)) { // Show an explanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the …

8
如何解决NoClassDefFoundError:无法解决以下问题:Landroid / view / View $ OnUnhandledKeyEventListener;
我已经将Android Studio升级到 Android Studio 3.2 Build #AI-181.5540.7.32.5014246, built on September 17, 2018 JRE: 1.8.0_152-release-1136-b06 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Mac OS X 10.11.6 我使用“空活动”模板创建一个新项目 Sync Gradle Clean Build Run 我的应用程序logcat在启动时显示此异常 2018-09-27 13:51:41.116 22090-22090/? I/zygote64: Rejecting re-init on previously-failed class java.lang.Class&lt;android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper&gt;: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener; 2018-09-27 …

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.