我的样式适用于我的整个应用程序:
AndroidManifest.xml中:
<application android:theme="@style/ApplicationStyle" android:icon="@drawable/icon" android:label="@string/app_name">
Run Code Online (Sandbox Code Playgroud)
在我的styles.xml中:
<style name="ApplicationStyle" parent="android:Theme">
<item name="android:button">@style/CKButton</item>
</style>
<style name="CKButton" parent="android:style/Widget.Button">
<item name="android:textSize">19sp</item>
<item name="android:layout_margin">0dip</item>
<item name="android:background">#ff0000</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但风格并未得到应用.
对不起,如果我只是在用假名字ApplicationStyle- Item,但我不知道在哪里找对象名称和简单的假设,即android:button适用于所有的按钮.
我想下载一个文件,需要检查响应状态代码(即HTTP /1.1 200 OK).这是我的代码剪辑:
HttpGet httpRequest = new HttpGet(myUri);
HttpEntity httpEntity = null;
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httpRequest);
...
Run Code Online (Sandbox Code Playgroud)
我如何获得响应的状态代码?
我有一个字符串表示包含空格的URL,并希望将其转换为URI对象.如果是简单的尝试
String myString = "http://myhost.com/media/File Name that has spaces inside.mp3";
URI myUri = new URI(myString);
Run Code Online (Sandbox Code Playgroud)
它给了我
java.net.URISyntaxException: Illegal character in path at index X
Run Code Online (Sandbox Code Playgroud)
其中index X是URL字符串中第一个空格的位置.
如何可以解析myString到一个URI对象?
可以以某种方式重命名预定义的构建类型吗?
我们使用一些自定义构建类型来表示我们的内部登台设置(DEV/TEST/LIVE),并且不需要构建buildTypes(发布/调试).这些可以在调用时以某种方式被重命名或禁用assemble吗?
我想确保LocationListener接收的位置是"真实的",并且不是来自欺骗性的源(即应用程序位置欺骗器).我不关心"但用户有时想欺骗位置" - 它是关于一个不会在Android市场上分发的应用程序.应用程序不需要位置准确 - 它只需要"真实".
你认为有办法检查这个位置是否被欺骗了吗?
你认为什么是防止位置欺骗的好方法?
有没有一个android方法可以给我真正的位置呢?
是否可能有一个android方法来确定该位置是否已被欺骗?
我的想法:
请告诉我你对这个问题的想法和意见.
有没有办法检测Retrofit响应是来自配置的OkHttp缓存还是实时响应?
客户定义:
Cache cache = new Cache(getCacheDirectory(context), 1024 * 1024 * 10);
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.cache(cache)
.build();
Run Code Online (Sandbox Code Playgroud)
Api定义:
@GET("/object")
Observable<Result<SomeObject>> getSomeObject();
Run Code Online (Sandbox Code Playgroud)
示例电话:
RetroApi retroApi = new Retrofit.Builder()
.client(okHttpClient)
.baseUrl(baseUrl)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(RetroApi.class);
result = retroApi.getSomeObject().subscribe((Result<SomeObject> someObjectResult) -> {
isFromCache(someObjectResult); // ???
});
Run Code Online (Sandbox Code Playgroud) 我想在按下Menu手机上的按钮时执行自定义操作.
是否可以在按钮上设置onClickListener(或类似),如果是,如何?
onCreateOptionsMenu 仅在第一次按下按钮时调用 - 我已经尝试过了.
我想在我的应用程序中显示选项卡但默认情况下在android之间的选项卡中有这样的分隔线
Tab1 | Tab2 | Tab3 |
Run Code Online (Sandbox Code Playgroud)
但我想显示这样的标签
Tab1 Tab2 Tab3
Run Code Online (Sandbox Code Playgroud)
所以我想删除两个标签之间的分隔线,默认情况下标签背景颜色是灰色.所以我想把它变成黑色.
请告诉我们如何删除两个选项卡之间的分隔线并更改选项卡的背景颜色.
提前致谢.
最好的祝福.
我正在尝试让 Room( https://developer.android.com/topic/libraries/architecture/room ) 与 Kotlin 的内联类一起工作,如Jake Whartons 文章内联类制作出色的数据库 ID 中所述:
@Entity
data class MyEntity(
@PrimaryKey val id: ID,
val title: String
)
inline class ID(val value: String)
Run Code Online (Sandbox Code Playgroud)
编译这个房间时抱怨说
实体和 Pojo 必须有一个可用的公共构造函数。您可以拥有一个空构造函数或一个其参数与字段(按名称和类型)匹配的构造函数。
查看生成的 Java 代码,我发现:
private MyEntity(String id, String title) {
this.id = id;
this.title = title;
}
// $FF: synthetic method
public MyEntity(String id, String title, DefaultConstructorMarker $constructor_marker) {
this(id, title);
}
Run Code Online (Sandbox Code Playgroud)
神秘的是,默认构造函数现在是私有的。
当String用作id( 或 a typealias)的类型时,生成的 Java 类构造函数看起来像预期的那样: …
我想做一个类似于这个的布局:
www.ImageBanana.net - layout.png http://www.imagebanana.com/img/9kmlhy66/thumb/layout.png
屏幕上有四个方形按钮 - 每个按钮使用屏幕的一半/屏幕高度(以较小者为准).与屏幕尺寸/分辨率无关.
我已经尝试通过使用a实现这一点,LinearLayout但按钮最终使用正确的宽度,但仍然具有背景的高度(不再是正方形).
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_height="wrap_content"
style="@style/CKMainButton"
android:layout_width="fill_parent"
android:text="@string/sights"
android:id="@+id/ApplicationMainSight"
android:layout_toLeftOf="@+id/ApplicationMainEvent"></Button>
<Button
android:layout_height="wrap_content"
style="@style/CKMainButton"
android:layout_width="fill_parent"
android:text="@string/sights"
android:id="@+id/ApplicationMainSight"
android:layout_toLeftOf="@+id/ApplicationMainEvent"></Button>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_height="wrap_content"
style="@style/CKMainButton"
android:layout_weight="1"
android:layout_width="fill_parent"
android:text="@string/usergenerated"
android:id="@+id/ApplicationMainUserGenerated" />
<Button
android:layout_height="wrap_content"
style="@style/CKMainButton"
android:layout_weight="1"
android:layout_width="fill_parent"
android:text="@string/tours"
android:id="@+id/ApplicationMainTour"/>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
它看起来像这样:www.ImageBanana.net - layout2.png http://www.imagebanana.com/img/i2ni6g4/thumb/layout2.png
我怎样才能使布局看起来像上面的图像?
android ×10
httprequest ×2
java ×2
android-room ×1
button ×1
gps ×1
gradle ×1
httpclient ×1
kotlin ×1
layout ×1
location ×1
okhttp ×1
okhttp3 ×1
optionmenu ×1
position ×1
retrofit2 ×1
stylesheet ×1
tabs ×1
uri ×1
url ×1
xml ×1
xslt ×1