野兔是我的应用程式:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.atumanin.testandroidannotations"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.1.18"
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'io.reactivex.rxjava2:rxjava:2.1.6'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
}
Run Code Online (Sandbox Code Playgroud)
这是我的项目gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete …Run Code Online (Sandbox Code Playgroud) 这里有很多相同的问题.我尝试了所有的解决方案 - 没什
我想用javascript在一些标签页面打开新页面.这是我的HTML:
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" ></script>
<script src="functions.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body>
...
<label>
<input type="image" name="imageField" id="loginClient" onclick="testUrl()" src="images/index_33.gif" />
</label>
...
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的functions.js:
function testUrl()
{
window.location = "content.html";
}
function loginClient()
...//more functions
Run Code Online (Sandbox Code Playgroud)
我也尝试了其他方法:
window.location.replace("content.html")
top.location="content.html"
window.location.assign("content.html")
window.open("content.html", "_self")
window.location.href="content.html"
window.event.returnValue = false;
window.location = "content.html";
setTimeout(function(){window.location.assign("content.html");return false;},500)
Run Code Online (Sandbox Code Playgroud)
没有用,我在Opera,Firefox(全部在Windows)和Chrome(Debian)中尝试过.但如果我设置:
window.open("content.html")
Run Code Online (Sandbox Code Playgroud)
但在新标签中,不是解决方案,我需要在同一个标签中.
但是,如果我尝试使用Firebug进行调试并点击始终"Step into"而不是所有解决方案的工作.如果我在重定向之前设置alert(),它也可以.
控制台显示没有错误.我不知道,帮帮忙.
决议:感谢@lonesomeday!
这是解决方案:
$(document).ready(function(){
$("#loginClient").click(function(event){
event.preventDefault();
window.location = "content.html";
});
});
Run Code Online (Sandbox Code Playgroud) 我有一个DialogFragment,其中是一个带有一些EditText字段的ScrollView.如果用户按下最后一个,则应将其移动到标题下方的对话框的顶部.如果我只使用scrollView.smoothScrollTo(0,view)滚动到此字段,它只会出现在软键盘上,但仍显示最后一个字段上的其他字段.如果我将所有字段的可见性设置为"GONE"以上,它可以正常工作,但用户无法向后滚动,但我需要它.我不知道在Android上是否可行.有人可以帮帮我吗?我花了三天时间解决这个问题,但找不到解决方案.任何帮助将不胜感激!
编辑:截图这就是我所拥有的:

我需要什么:

android android-animation android-edittext android-scrollview
在我的应用程序中,无论眼镜是否在移动,我都需要测量相机数据。我得到的数据:
quaternions["x"] = Camera.main.transform.rotation.x;
quaternions["y"] = Camera.main.transform.rotation.y;
quaternions["z"] = Camera.main.transform.rotation.z;
quaternions["w"] = Camera.main.transform.rotation.w;
quaternions["tx"] = Camera.main.transform.position.x;
quaternions["ty"] = Camera.main.transform.position.y;
quaternions["tz"] = Camera.main.transform.position.z;
Run Code Online (Sandbox Code Playgroud)
如果我移动眼镜,则该应用程序可以正常运行。但是,如果我将眼镜放在桌子上,则4分钟后眼镜将无法显示,并且代码将返回最后存储的数据。即使已插入充电电缆。如果按眼镜上的启用按钮,则显示屏将再次打开并且数据也正确。
有没有可能防止眼镜入睡?
我的启动画面是一个layer-list可绘制的应用程序主题背景。就这个:
background_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/dark_blue"/>
<item android:top="100dp">
<bitmap
android:gravity="top"
android:src="@mipmap/img_logo"/>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
如您所见,我将徽标放置100dp在顶部留有边距。然后我尝试在我的片段布局中做同样的事情:
fragment_start.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/bg_create_account">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/img_logo"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
但是布局中的徽标比启动屏幕上的徽标低。我想,问题出在Activity. 但如果我设置:
<dimen name="activity_horizontal_margin">0dp</dimen>
<dimen name="activity_vertical_margin">0dp</dimen>
Run Code Online (Sandbox Code Playgroud)
什么都没有发生。我总是看到徽标从上到下的“跳跃”大约 10-20 dp。我怎样才能避免它?
编辑:我的活动xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
编辑 2:我尝试手动获取距离,如果我设置<item android:top="125dp">(或 126dp)并离开,android:layout_marginTop="100dp"我看不到“跳跃”。这意味着差异是 25 或 26 dp,但它们在哪里?
编辑 3:根据 Bryan …
我收到一个奇怪的错误:
java.lang.IllegalStateException: Fragment DetailFragment{478548c} (790a9d4b-aae5-425a-a41d-2ab5785e5479) id=0x7f0b1c79 DetailFragment} did not return a View from onCreateView() or this was called before onCreateView().
at androidx.fragment.app.Fragment.requireView(SourceFile:1781)
at androidx.fragment.app.FragmentTransition.captureOutSharedElements(SourceFile:846)
at androidx.fragment.app.FragmentTransition.configureSharedElementsOrdered(SourceFile:758)
at androidx.fragment.app.FragmentTransition.configureTransitionsOrdered(SourceFile:378)
at androidx.fragment.app.FragmentTransition.startTransitions(SourceFile:155)
at androidx.fragment.app.FragmentManager.executeOpsTogether(SourceFile:2001)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(SourceFile:1959)
at androidx.fragment.app.FragmentManager.execPendingActions(SourceFile:1861)
at androidx.fragment.app.FragmentManager$4.run(SourceFile:413)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Run Code Online (Sandbox Code Playgroud)
到目前为止,该错误在不同设备上只发生了 3 次。与应用程序的使用相比,这真的很少。我无法重现它。根据我们的跟踪,当用户按下此片段时就会发生这种情况。该片段不会覆盖,onBackPressed()但父级会覆盖它,并且没有什么可以帮助我认识到问题:
public boolean onBackPressed() {
return false;
}
Run Code Online (Sandbox Code Playgroud)
所以我不知道在哪里搜索该错误。
编辑:这个片段也不会覆盖onCreateView(),它会覆盖父级:
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) …Run Code Online (Sandbox Code Playgroud) 我使用RPi3和Android Things 0.5.1.虽然我有我AndroidManifest.xml的许可:
<uses-permission android:name="com.google.android.things.permission.MANAGE_INPUT_DRIVERS" />
Run Code Online (Sandbox Code Playgroud)
我得到了例外:
java.lang.SecurityException: Caller lacks required permission com.google.android.things.permission.MANAGE_INPUT_DRIVERS
Run Code Online (Sandbox Code Playgroud)
有人在0.5.1上获得了这个许可吗?
我有包含三个片段的 ViewPager,其中一个是 FrameLayout,里面有 ScrollView:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
</ScrollView>
<Button
android:id="@+id/buttonRemove"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_button_red"
android:layout_gravity="bottom"
android:layout_margin="4dp"
android:text="@string/button_remove_last_round"
android:textColor="#ffffff"
android:textSize="24sp"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
如果我滑过按钮,它就可以工作。但是如果我在 ScrollView 上滑动,它不起作用,只能向上/向下滚动
编辑:我试图覆盖 Scrollview 的 OnTouchEvent:
@Override
public boolean onTouchEvent(MotionEvent ev) {
switch (ev.getAction()){
case MotionEvent.ACTION_DOWN:
touchX = ev.getX();
touchY = ev.getY();
return super.onTouchEvent(ev);//if I change it to 'break', then only swipe works, but no scroll
case MotionEvent.ACTION_MOVE:
if(Math.abs(touchX-ev.getX())<40){
return super.onTouchEvent(ev);//Scroll works perfectly
}else{
return false;//Scroll disabled, but swipe still …Run Code Online (Sandbox Code Playgroud) 我想创建一个具有缩放设置、标记和地图类型设置的自定义地图片段,以便我可以在多个活动中重复使用它。我创建的类称为“LiteMap”。
\n\n我从编译器处收到错误 \n \'Incompatible Types\' \'Required: com.mypackage.LiteMap\' \'Found com.google.android.gms.maps.SupportMapFragment\'\n我调用.newInstance. 我假设.newInstance返回父类而不是我的类,但我不确定如何在我的类中重写以返回我的“LiteMap”对象。
作为替代方案,我尝试使用 new 实例化我的地图对象,并且在没有任何特定行作为源的情况下收到以下错误,但似乎使用 new 并没有创建 LiteMap 对象。我想做的事情是不可能的还是愚蠢的做法?
\n\n03-29 20:36:52.771 11326-11326/com.tremulant.phield E/AndroidRuntime: FATAL EXCEPTION: main\n Process: com.tremulant.phield, PID: 11326\n java.lang.RuntimeException: Unable to resume activity {com.tremulant.phield/com.tremulant.phield.ReviewDetails}: java.lang.NullPointerException: Attempt to invoke interface method \'void maps.ei.bz.o()\' on a null object reference\n at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2974)\n at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3005)\n at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2371)\n at android.app.ActivityThread.access$800(ActivityThread.java:149)\n at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)\n at android.os.Handler.dispatchMessage(Handler.java:102)\n at android.os.Looper.loop(Looper.java:135)\n at android.app.ActivityThread.main(ActivityThread.java:5290)\n at java.lang.reflect.Method.invoke(Native Method)\n at java.lang.reflect.Method.invoke(Method.java:372)\n at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)\n at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)\n …Run Code Online (Sandbox Code Playgroud) android ×6
c# ×1
fragment ×1
hololens ×1
html ×1
java ×1
javascript ×1
rx-android ×1
rx-java2 ×1
uwp ×1