我想在我的ipad上测试Safari上的网站.我只有另一台电脑.有没有办法像移动Chrome一样进行ADB等远程调试?我在StackOverflow上搜索,似乎有一个Adobe Edge Inspect CC,但我不知道这是不是一个好选择.
谢谢!
考虑以下布局文件:
<?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>
Run Code Online (Sandbox Code Playgroud)
我不确定app:layout_constraintDimensionRatio是如何工作的.我的理解是比例总是宽度:高度.因此3:1将始终使ImageView看起来比高度宽3倍.前缀H或W告诉ConstraintLayout哪个维度应该尊重比率.如果是H则表示首先根据其他约束计算宽度,然后根据纵横比调整高度.然而,这是布局的结果:
高度是宽度的3倍,这是意料之外的.任何人都可以向我解释如何计算尺寸相对于app:layout_constraintDimensionRatio设置?
android scale aspect-ratio android-layout android-constraintlayout
我在stackoverflow上发现了很多帖子,但我仍然无法解决我的问题.这是我的代码片段:
public class MyView extends RelativeLayout {
Button b1;
Button b2;
Context sContext;
public static int i = 0;
private int w = 400;
private int h = 400;
private int w2 = 100;
private int h2 = 100;
public MyView(Context context) {
super(context);
sContext = context;
init();
}
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
sContext = context;
init();
}
private void init() {
b1 = new Button(sContext);
addView(b1);
b1.setBackgroundColor(Color.YELLOW);
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) …Run Code Online (Sandbox Code Playgroud) HTML文件中有两种类型的链接:
(1) A normal link like http://www.bbb.com/q?type=normal
(2) A short link like /q?type=short.
Run Code Online (Sandbox Code Playgroud)
对于第一种,只需加载网址.对于第二种,我应该在加载URL之前使用固定地址(如http://www.abc.com).
我试图通过覆盖WebViewClient中的shouldOverrideUrlLoading()函数来做到这一点.但是,不会为第二种类型的链接调用此函数.我尝试将" http://www.abc.com " 添加到HTML文件中的第二种类型的链接.然后当我点击第二种链接时,会调用该函数.
我认为发生的事情是WebView将首先检查链接是否是有效的URL.只有它有效才会调用该函数.我对吗?我怎么解决这个问题?提前致谢.
contentWebView = new WebView(context);
webViewClient = new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// String not in Logger.
Log.d(TAG, "Here!");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(intent);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
if …Run Code Online (Sandbox Code Playgroud) 这是我试图解决的问题,我试图使用void类型作为泛型类型:
class Parent {
private abstract class Item<out T>(val data: T)
// This subclass should contain data
private class ItemContent(val data: String): Item<String>(data)
// This subclass doesn't contain data
private class ItemNoContent: Item<Any?>(null)
}
Run Code Online (Sandbox Code Playgroud)
像ItemNoContent这样的基类不包含有意义的数据,因此我使ItemNoContent扩展Item(null).它有效,但我觉得使用Any?和null在这里不合适.是否有更多的Kotlin方法来解决这个可选的通用问题?
我的春季启动应用程序总是在早上向我显示此whitelabel错误:无法打开JPA EntityManager进行事务处理; 嵌套异常是javax.persistence.PersistenceException:org.hibernate.TransactionException:JDBC开始事务失败:
我搜索网络我认为可能是mysql关闭连接8小时不活动.但是根据文档spring boot会自动配置池化apache数据源.http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-sql.html
我不知道如何配置应用程序代码或数据库.
这是我正在使用的build.gradle:
buildscript {
ext {
springBootVersion = '1.2.3.RELEASE'
}
repositories {
maven { url "http://repo.spring.io/libs-snapshot" }
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
apply plugin: 'application'
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
maven { url "http://maven.springframework.org/milestone" }
}
// Seems tomcat 8 doesn't work with paypal
configurations.all {
resolutionStrategy {
eachDependency {
if (it.requested.group == 'org.apache.tomcat.embed') …Run Code Online (Sandbox Code Playgroud) 我试图将/ system重新安装为rw文件系统,以便将一些文件推送到/ system/framework.它是运行Android 6.0 x86映像的Android模拟器.
$ mount
...
/dev/block/vda /system ext4 ro,seclabel,relatime,data=ordered 0 0
...
Run Code Online (Sandbox Code Playgroud)
然后我做
su
mount -o rw,remount /system
mount
...
/dev/block/vda /system ext4 rw,seclabel,relatime,data=ordered 0 0
...
Run Code Online (Sandbox Code Playgroud)
这时候我觉得我很好.然后我在主持人做:
adb push test.jar /system/framework/
Run Code Online (Sandbox Code Playgroud)
不过我看到了:
failed to copy 'test.jar' to '/system/framework/test.jar': Read-only file system
Run Code Online (Sandbox Code Playgroud)
然后我回到adb:
mount
...
/dev/block/vda /system ext4 ro,seclabel,relatime,data=ordered 0 0
...
Run Code Online (Sandbox Code Playgroud)
它又回到了ro.
当我试图再次重新安装时,它甚至不让我这次做:
mount: Read-only file system
255|root@generic_x86:/ #
Run Code Online (Sandbox Code Playgroud)
那我在哪里做错了?谢谢!
___编辑_____
通过adb root命令以root身份重新启动adbd解决了我的问题.
我使用TextView来显示HTML字符串,例如:
"测试HTML <a href = \"www.type1.com \"> link1 </ a> <a href = \"www.type2.com \"> link2 </ a>"
如您所见,我需要处理两种不同的标记,因此我需要能够处理两种不同类型的标记并读取href属性.
我尝试使用Html.TagHandler:
private class MyTagHandler implements Html.TagHandler {
@Override
public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) {
Toast.makeText(getContext(), tag, Toast.LENGTH_LONG).show();
}
}
Run Code Online (Sandbox Code Playgroud)
但是,在<a>标记上未调用handleTag.我做了测试并发现它只对自定义标签有影响.是否也可以处理标准标签?
我正在实现一个WebView,它可以根据内容高度调整其高度.我试着做以下事情:
WebView view = new WebView(context);
view.loadData(htmlString, "text/html", "utf-8");
view.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
Log.d("2", view.getContentheight() + "");
// Set the height of the webview to view.getContentHeight() here?
}
});
Log.d("1", view.getContentHeight() + "");
Run Code Online (Sandbox Code Playgroud)
其中htmlString是HTML格式的String.
但是两个Logs都返回0.
我不确定我做的是否正确.如何知道内容高度,然后相应地设置WebView的高度?
考虑这个布局:
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="160dp"
android:textSize="20sp"
android:text="Apple Inc. is an American multinational technology company headquartered in Cupertino, California, that designs, develops, and sells consumer electronics, computer software, and online services."
android:ellipsize="end"
android:gravity="top"/>
Run Code Online (Sandbox Code Playgroud)
我希望 TextView 做的是弄清楚它可以在 160dp 中容纳多少行,如果空间不够,则放置三个点。然而,文本被截断了:

我怎样才能实现上述行为?我假设我可以通过在布局资源文件上指定一些属性来做到这一点。谢谢。