Questions tagged «android»

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

12
检测ScrollView的结尾
我有一个应用程序,该应用程序的活动使用ScrollView。我需要检测用户何时到达底部ScrollView。我做了一些谷歌搜索,我找到了解释的页面。但是,在这个例子中,这些家伙扩展了ScrollView。如我所说,我需要扩展Activity。 因此,我说“好吧,让我们尝试使自定义类扩展ScrollView,覆盖onScrollChanged()方法,检测滚动的结尾并采取相应的措施”。 我做了,但是在这一行: scroll = (ScrollViewExt) findViewById(R.id.scrollView1); 它抛出一个 java.lang.ClassCastException。我更改了<ScrollView>XML中的标签,但是显然不起作用。我的问题是:为什么,如果ScrollViewExt延伸ScrollView,会丢给我一个ClassCastException?有什么方法可以检测滚动结束而不会造成太多混乱? 谢谢大家 编辑:如所承诺的,这是我重要的XML片段: <ScrollView android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="match_parent" > <WebView android:id="@+id/textterms" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal" android:textColor="@android:color/black" /> </ScrollView> 我将其从更改TextView为WebView,以便能够证明其中的文本。我要实现的是“接受按钮直到合同的条款全部阅读后才激活”的东西。我的延伸班级叫ScrollViewExt。如果我更改标签ScrollView,ScrollViewExt它会抛出一个 android.view.InflateException: Binary XML file line #44: Error inflating class ScrollViewExt 因为它不了解标签ScrollViewEx。我认为这没有解决方案... 感谢您的回答!



10
文件存在且位于IS目录中,但listFiles()返回null
的文档File.listFiles()建议null仅在调用它的文件不是目录的情况下才返回。 我有以下内容: String dir = "/storage/emulated/0"; File f = new File(dir); Log.v("Files",f.exists()+""); Log.v("Files",f.isDirectory()+""); Log.v("Files",f.listFiles()+""); 日志显示为: true true null 由于某种原因,即使将该识别为有效目录,listFiles(也仍会返回)。我对Android文件层次结构的行为不是很熟悉,所以我猜问题出在这里。nullFile 作为参考,我正在Moto X上进行调试,无论手机是否插入计算机,结果都是相同的-因此,我认为插入手机与安装无关。


10
由于输入结束杰克逊解析器,无法映射任何内容
我正在从服务器收到此响应 {"status":"true","msg":"success"} 我正在尝试使用Jackson解析器库解析此json字符串,但不知何故我正面临着映射异常说明 com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input at [Source: java.io.StringReader@421ea4c0; line: 1, column: 1] 为什么会出现这种例外情况? 如何理解导致此异常的原因? 我正在尝试使用以下方式进行解析: StatusResponses loginValidator = null; ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(Feature.AUTO_CLOSE_SOURCE, true); try { String res = result.getResponseAsString();//{"status":"true","msg":"success"} loginValidator = objectMapper.readValue(result.getResponseAsString(), StatusResponses.class); } catch (Exception e) { e.printStackTrace(); } StatusResponse类 …
76 java  android  json  jackson 


3
ConstraintLayout纵横比
考虑以下布局文件: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.constraint.ConstraintLayout android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FF0000" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"> <ImageView android:layout_width="0dp" android:layout_height="0dp" android:background="#0000FF" android:padding="16dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintDimensionRatio="H,3:1" tools:layout_editor_absoluteX="16dp" /> </android.support.constraint.ConstraintLayout> </RelativeLayout> 我不确定app:layout_constraintDimensionRatio的工作方式。我的理解是比率将始终是宽度:高度。因此3:1将始终使ImageView出现的宽度是高度的3倍。前缀H或W告诉ConstraintLayout哪个尺寸应遵守该比率。如果为H,则意味着将首先根据其他约束条件计算宽度,然后根据宽高比调整高度。但这是布局的结果: 高度是宽度的3倍,这是意外的。谁能向我解释如何针对app:layout_constraintDimensionRatio设置计算尺寸?

7
计算两个地理位置之间的距离
请阐明这种情况 现在,我有两个数组,它们具有附近地点的经度和纬度,并且还具有用户位置latiude和longiude现在,我想计算用户位置和附近地点之间的距离,并希望在listview中显示它们。 我知道有一种方法可以计算距离 public static void distanceBetween (double startLatitude, double startLongitude, double endLatitude, double endLongitude, float[] results); 现在的问题是,在这种方法中如何通过这两个具有附近纬度和经度的数组,并获得距离数组。

8
如何更改按钮上的drawableLeft图标大小?
我在4个按钮上添加了一些图标,它们在按钮旁边看起来很大。那么如何调整它们的大小?我在按钮上使用了drawableLeft来添加图标。 可绘制对象称为交易,奖杯,拼图和扩音器。图标太大。content_main.xml文件: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/content_main" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="tr.k12.evrim.evrimnews.MainActivity" tools:showIn="@layout/activity_main"> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/frameLayout" android:layout_alignParentTop="true" android:layout_alignParentStart="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Giriş Yap" android:onClick="SignIn" android:textStyle="bold" style="@style/Widget.AppCompat.Button.Colored"/> </LinearLayout> </FrameLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="400dp" android:layout_below="@id/frameLayout" android:orientation="vertical"> <Button android:text="Duyurular" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:layout_below="@+id/frameLayout" …
76 android 

5
Retrofit2授权-访问令牌的全局拦截器
我正在尝试使用Retrofit2,我想添加Token到我的Header像这样: Authorization: Bearer Token 但code以下内容不起作用: public interface APIService { @Headers({"Authorization", "Bearer "+ token}) @GET("api/Profiles/GetProfile?id={id}") Call<UserProfile> getUser(@Path("id") String id); } 我的服务器是asp.net webApi。请帮我该怎么办?

3
Android锁屏小部件
一些用户一直在问我我的应用程序的Android锁定屏幕小部件-我相信他们想要一个保留在锁定屏幕上并允许他们与该应用程序交互的小部件。 我至今尚未找到任何官方文档-我发现的唯一一件事就是将主屏幕小部件放置在锁定屏幕上的应用程序。 关于我在哪里了解有关构建真正的锁屏小部件的更多信息?



4
展开/折叠Lollipop工具栏动画(Telegram应用程序)
我试图弄清楚工具栏的展开/折叠动画是如何完成的。如果您查看Telegram应用程序设置,将会看到有一个列表视图和工具栏。向下滚动时,工具栏将折叠,而向上滚动时,工具栏将展开。还有个人资料图片和FAB的动画。有人对此有任何线索吗?您是否认为他们在其之上构建了所​​有动画?也许我缺少新的API或支持库中的内容。 当您打开微调器时,我在Google日历应用程序中注意到了相同的行为(我不认为它是微调器,但看起来像):工具栏展开,向上滚动时,它折叠。 只是要澄清一下:我不需要QuickReturn方法。我知道,Telegram应用程序可能正在使用类似的东西。我需要的确切方法是Google日历应用效果。我尝试过 android:animateLayoutChanges="true" 并且expand方法效果很好。但是显然,如果我向上滚动ListView,工具栏不会折叠。 我还考虑过添加一个,GestureListener但是我想知道是否有任何API或更简单的方法来实现。 如果没有,我想我会去的GestureListener。希望能有流畅的动画效果。 谢谢!

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.