如何在我的应用程序中设置黑暗的全息主题?这时我得到了这个:
<style name="AppTheme" parent="android:Theme.Holo.Light" />
Run Code Online (Sandbox Code Playgroud)
但当我把它改为:
<style name="AppTheme" parent="android:Theme.Holo.Dark" />
Run Code Online (Sandbox Code Playgroud)
我收到一个错误 error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Dark'.
如何解决问题?
我有一个ListView的setEmptyView方法的问题.
这是我的Java代码:
ListView view = (ListView)findViewById(R.id.listView1);
view.setEmptyView(findViewById(R.layout.empty_list_item));
ArrayAdapter<Session> adapter1 = new ArrayAdapter<Session>(this, android.R.layout.simple_list_item_1,
android.R.id.text1, MainController.getInstanz().getItems());
view.setAdapter(adapter1);
Run Code Online (Sandbox Code Playgroud)
empty_list_item:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/emptyList" >
</TextView>
Run Code Online (Sandbox Code Playgroud)
列表显示:
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
Run Code Online (Sandbox Code Playgroud)
我的代码出了什么问题?当我有物品时,我会在列表中看到它们.但是当列表为空时我看不到TextView.
我有以下代码,我对此错误消息感到困惑:
实例成员'mydate'不能用于'TableViewController'类型
码:
class TableViewController: UITableViewController {
let mydate = NSDate()
let items = [
(1, 9, 7, "A", mydate),
(2, 9, 7, "B", mydate),
(3, 9, 7, "C", mydate),
(4, 9, 7, "D", mydate)
]
Run Code Online (Sandbox Code Playgroud)
当我写下面的内容时,我可以构建它,但我不知道为什么oder片段不起作用:
class TableViewController: UITableViewController {
let mydate = NSDate()
let items = [
(1, 9, 7, "A", nil),
(2, 9, 7, "B", mydate),
(3, 9, 7, "C", mydate),
(4, 9, 7, "D", mydate)
]
Run Code Online (Sandbox Code Playgroud) 如何从RGB代码中Brush设置例如a的背景Grid.
我认为RGB代码是int:
R = 12
B = 0
G = 255
Run Code Online (Sandbox Code Playgroud)
我需要知道如何将其转换为 Brush
我需要做以下事情:我在地图上有一个标记,我需要改变它的位置.所以我尝试了以下方法:
MarkerOptions a = new MarkerOptions()
.position(new LatLng(50,6)));
map.addMarker(a);
a.position(new LatLng(50,5));
Run Code Online (Sandbox Code Playgroud)
地图是一个GoogleMap.我想我必须刷新地图或平等吗?
如果点击发生在应用程序屏幕的某个位置,我该如何捕获事件?是否有按钮或其他内容无关紧要.我只需要onClick()在整个应用程序屏幕上应用事件监听器.
这该怎么做?
我想运行以下测试:
package com.xxx.yyy;
import android.content.Context;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.xxx.yyy", appContext.getPackageName());
}
}
Run Code Online (Sandbox Code Playgroud)
但我在控制台中收到错误:
$ adb shell am instrument -w -r -e debug false -e class 'com.xxx.yyy.ExampleInstrumentedTest' com.xxx.yyy.test/android.support.test.runner.AndroidJUnitRunner
Client not ready yet..
Started running …Run Code Online (Sandbox Code Playgroud) 我的预览中出现以下错误:
struct DetailView: View {
var header: DataProvider.DataHeader
var body: some View {
Text("...")
}
}
struct DetailView_Previews: PreviewProvider {
var a = DataProvider.DataHeader(title: "a", text: "b")
static var previews: some View {
DetailView(header: a)
}
}
Run Code Online (Sandbox Code Playgroud)
错误是:
Instance member 'a' cannot be used on type 'DetailView_Previews'
Run Code Online (Sandbox Code Playgroud)
为什么会发生这种情况?
我正在尝试使用检测测试,并将我的项目更新为AndroidX.但是在尝试运行时出现以下错误:
2018-10-09 14:22:29.468 13263-13263/xxx.yyy E/AndroidRuntime: FATAL EXCEPTION: main
Process: xxx.yyy, PID: 13263
java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{xxx.yyy.test/android.support.test.runner.AndroidJUnitRunner}: java.lang.ClassNotFoundException: Didn't find class "android.support.test.runner.AndroidJUnitRunner" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5730)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.test.runner.AndroidJUnitRunner" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5728)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method) …Run Code Online (Sandbox Code Playgroud) 我有这样的方法:
Integer.parseInt(myInt)
Run Code Online (Sandbox Code Playgroud)
不是这个整数变得很长,我得到以下异常:
java.lang.NumberFormatException: For input string: "4000123012"
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能避免这个错误并仍然保持功能运行?
我尝试使用BigInteger但没有parse方法,或者我没有找到它.