嗨我想将图像设置为FloatingActionButton我这样做:
<android.support.design.widget.FloatingActionButton
android:id="@+id/qick_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:src="@drawable/quick_menu"
app:elevation="7dp"
app:layout_anchor="@id/mapview"
app:layout_anchorGravity="bottom|right|end" />
Run Code Online (Sandbox Code Playgroud)
但我的按钮中有一个小图像
嗨,我想在tablewView的列内的文本上设置字体。我如何在Java中执行此操作是我的代码。感谢帮助。
private final TableView<AnotherBus> table = new TableView<>();
TableColumn busNumberCol = new TableColumn("Linia");
busNumberCol.setCellValueFactory(
new PropertyValueFactory<>("busNumber"));
busNumberCol.getStyleClass().add("Times New Roman,40");
tb.getStyleClass().add("Times New Roman");
TableColumn courseCol = new TableColumn("Kierunek");
courseCol.setCellValueFactory(
new PropertyValueFactory<>("nameBusStpo"));
courseCol.setPrefWidth(200);
courseCol.getStyleClass().add("Times New Roman");
TableColumn departureCol = new TableColumn("Odjazd");
departureCol.setCellValueFactory(
new PropertyValueFactory<>("busTimetable"));
table.setItems(list);
table.getColumns().addAll(busNumberCol, courseCol, departureCol);
table.setPlaceholder(new Label(
""));
Run Code Online (Sandbox Code Playgroud) 我的应用程序是崩溃,在日志中我看到了这一点,我试图找到我如何解决它,但只有我发现这是因为一个上下文和一个人使用YourActivityName.this它工作正常,但我喜欢这个和我的应用程序崩溃了
这是日志:
Fatal Exception: android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@482fc81 is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:584)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:310)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:86)
at android.app.Dialog.show(Dialog.java:322)
at android.support.v7.app.AlertDialog$Builder.show(AlertDialog.java:953)
at pl.eltegps.smokkomunikator.ui.activity.MainActivity.runServices(MainActivity.java:505)
at pl.eltegps.smokkomunikator.ui.activity.MainActivity.onStart(MainActivity.java:316)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1238)
at android.app.Activity.performStart(Activity.java:6288)
at android.app.Activity.performRestart(Activity.java:6334)
at android.app.ActivityThread.handleSleeping(ActivityThread.java:3688)
at android.app.ActivityThread.access$2900(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1531)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5527)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Run Code Online (Sandbox Code Playgroud)
这是代码:
protected void runServices() {
if (LocationUtil.isLocationEnabled(getBaseContext())) {
if (checkPermission()) {
runLocationService();
}
} else {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setMessage(getResources().getString(R.string.location_settings_disabled));
dialog.setPositiveButton(getString(R.string.go_to_location_settings), …
Run Code Online (Sandbox Code Playgroud) 我想拍一张照片并在 imageView 中显示这张照片,它在 api 23 和 24 上无法正常工作我尝试添加了一个文件提供程序,这就是我所做的。
我的活动:
public class TestActivity extends AppCompatActivity {
ImageView iv;
private File photoFile;
private String mCurrentPhotoPath;
private static final String TAG = "PHOTO";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
iv = (ImageView) findViewById(R.id.iv);
photo();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
if (mCurrentPhotoPath != null) {
File file = new File(mCurrentPhotoPath);
if(file.exists())
Log.e(TAG , "photo jest");
try { …
Run Code Online (Sandbox Code Playgroud) 当我这样做时,我的应用程序崩溃:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Settings.System.canWrite(ListOfTerminalsActivity.this)) {
// Do stuff here
} else {
Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS);
intent.setData(Uri.parse("package:" + getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
Run Code Online (Sandbox Code Playgroud)
它发生在ZUK Z2的API 23上,这是日志;
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.action.MANAGE_WRITE_SETTINGS dat=package:pl.teminalmobile flg=0x10000000 }
01-24 12:33:56.123 30159 30159 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2464)
01-24 12:33:56.123 30159 30159 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2536)
01-24 12:33:56.123 30159 30159 E AndroidRuntime: at android.app.ActivityThread.access$900(ActivityThread.java:159)
01-24 12:33:56.123 30159 30159 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
01-24 12:33:56.123 30159 30159 E …
Run Code Online (Sandbox Code Playgroud) 嗨,我在 onCreate() 上创建了一个 Realm 接下来我想class CheckerThread extends AsyncTask<Void, String, Boolean>
在 doInBackground中公开存储一个日期,但我有一个
java.lang.IllegalStateException:来自不正确线程的领域访问。Realm 对象只能在创建它们的线程上访问。
onCreate 我有这个:
realm = RealmController.with(this).getRealm();
Run Code Online (Sandbox Code Playgroud)
接下来在 AsynTask 中,我下载了一个数据,我想保存它,我想在 doInBackground 中执行此操作,但是当我执行此操作时,我有:
Caused by: java.lang.IllegalStateException: Realm access from incorrect thread. Realm instance can only be closed on the thread it was created.
Run Code Online (Sandbox Code Playgroud)
我在 doInBackground 上这样做,但它没有帮助:
try {
realm = RealmController.with(getApplication()).getRealm();
RealmController.with(getApplication()).save(data);
}
finally {
realm.close();
}
Run Code Online (Sandbox Code Playgroud)
一个领域控制器;
public class RealmController {
private static RealmController instance;
private final Realm realm;
public RealmController(Application application) {
realm = Realm.getDefaultInstance();
} …
Run Code Online (Sandbox Code Playgroud) 这是我的目标:
public class ObjectsInGroupRealm extends RealmObject {
@PrimaryKey
private Long id;
private String name;
private String groupName;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
}
Run Code Online (Sandbox Code Playgroud)
当我创建一个新对象时,我想检查对象是否存在同一个名称和同一个groupName.对象名称可以在几个组中.这是我保存对象的代码:
public static void saveObjectsInGroup(ArrayList<String> objects, String groupName , Realm realm){
for(String object : …
Run Code Online (Sandbox Code Playgroud) 我使用 moshi 将 JSon 解析为 Object 。这是我的 JSon:
[{
"id": 4,
"phone": {
"id": 3,
"imei": "356938035643801",
"description": "Marek Kowalski"
},
"user": {
"id": 3,
"username": "marek.kowalski",
"first_name": "Marek",
"last_name": "Kowalski"
},
"user_id": 3,
"message": "Podejrzane zachowanie, sprawd??.",
"date_time_data": "2017-09-05T22:26:44.916927Z",
"longitude": 19.934113,
"latitude": 50.075086,
"confirm": 0,
"changetime": "2017-09-05T22:26:44.930357Z",
"has_coordinates": 1
}]
Run Code Online (Sandbox Code Playgroud)
这是我的对象:
public class Message {
String message;
double longitude;
double latitude;
int confirm;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
} …
Run Code Online (Sandbox Code Playgroud) 我在Api 18上这样做了它的工作原理:
String[] proj = new String[] { BookmarkColumns.TITLE,BookmarkColumns.URL };
Uri uriCustom = Uri.parse("content://com.android.chrome.browser/bookmarks");
String sel = BookmarkColumns.BOOKMARK + " = 0"; // 0 = history, 1 = bookmark
Cursor mCur = getContentResolver().query(uriCustom, proj, sel, null, null);
mCur.moveToFirst();
@SuppressWarnings("unused")
String title = "";
@SuppressWarnings("unused")
String url = "";
if (mCur.moveToFirst() && mCur.getCount() > 0) {
boolean cont = true;
while (mCur.isAfterLast() == false && cont) {
title = mCur.getString(mCur.getColumnIndex(BookmarkColumns.TITLE));
url = mCur.getString(mCur.getColumnIndex(BookmarkColumns.URL));
Log.e("title" , title);
Log.e("url" , url);
// Do …
Run Code Online (Sandbox Code Playgroud) 我使用一个android studio,当我刷新控制台中的所有gradle项目时,我有:
Error:(28, 0) Could not find method ndk() for arguments [build_drk092k49tm2cwy3k37ev72l6$_run_closure1$_closure7@6b46899]
on object of type com.android.build.gradle.AppExtension.
<a href="openFile:C:\Users\ElteGps 022\Desktop\PairingCodes\app\build.gradle">Open File</a>
Run Code Online (Sandbox Code Playgroud)
在邮件中,我看到:
找不到方法ndk()作为参数
这是我的build.gradle
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "smok.pl.pairingcodes"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
ndk {
moduleName "liblfrfid"
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
task …
Run Code Online (Sandbox Code Playgroud) 这是我的字符串地址:伦敦,Jon 2 A.
我希望在我的输出中看到伦敦,乔恩
我试着这样做:
String result = chapterNumber.substring(0, chapterNumber.indexOf("1"));
Run Code Online (Sandbox Code Playgroud)
但我必须从不同数量做10次也许是更好的方法来做到这一点