在我的应用程序中,我有一个使用Constraint Layout的自定义布局来显示两个视图,如下所示.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.constraint.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/guideline2"
android:orientation="horizontal"
tools:layout_editor_absoluteY="444dp"
tools:layout_editor_absoluteX="0dp"
app:layout_constraintGuide_percent="0.5"/>
<CategorySelectionLayout
android:id="@+id/categoryList"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
android:gravity="center_vertical"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<CategoryNavigationLayout
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingLeft="@dimen/one_grid"
tools:layout_manager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/order_selection_item"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintBottom_toTopOf="@+id/guideline2" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
现在想象当categoryList中没有任何内容显示时,我想隐藏它(View.GONE)然后调整约束布局的大小以仅使用导航布局所需的空间.
我试图在自定义视图中设置可见性.
this.visibility = View.GONE
this.parent.requestLayout()
Run Code Online (Sandbox Code Playgroud)
视图现在已隐藏,但父级未相应调整大小.
那么如何强制这个ConstraintLayout重新调整它的大小呢?
我正在尝试在我的应用程序中使用HoloEverywhere库的dev分支.我知道这仍然是在开发期间,但演示似乎工作正常,所以我试一试.
我在我的清单中的活动中放了android:theme ="@ style/Holo.Theme.Sherlock.Light".活动的结构是它使用Fragment,一个是列表,另一个是Fragment.ActionBar看起来很好.
我把我的SherlockFragmentActivity转化为SActivity和Fragment成SFragment.就像我在附带的演示应用程序中查看一样.我在SFragment中使用这段代码打开对话框.
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Work in Progress")
.setView(inflater.inflate(R.layout.extra_input))
.setIcon(R.drawable.icon);
builder.setPositiveButton("Positive", null);
builder.setNegativeButton("Negative", null);
builder.setNeutralButton("Neutral", null);
builder.show();
Run Code Online (Sandbox Code Playgroud)
弹出的对话框看起来像操作系统的AlertDialog,其中extra_input布局中的EditText显示为Holo.ProgressDialog也会显示OS的主题.
我相信这是我错误地实现了库.问题是如何正确地做到这一点?
编辑:解决了它,我需要使用com.WazaBe.HoloEverywhere.app.AlertDialog而不是android.app.AlertDialog.傻我.
在这个例子中,我必须上课.
Order(selections: List<Selection>, discount: Double, ...)
Selection(productId: Long, price: Double, ...)
Run Code Online (Sandbox Code Playgroud)
然后我继续收集Order
我想要计算之后需要使用的价格Selection's price
和Order's discount
.我怎样才能做到这一点?
我尝试执行以下操作,但似乎不可能.
val orderList: List<Order> = loadFromDB()
orderList.map { Pair(it.selections, it.discount) }
.flatMap { /* Here I want to get list of Pair of selection from all orders with discount. */}
Run Code Online (Sandbox Code Playgroud)
一旦我收集了,Pair(Selection, discount)
那么我可以继续进一步计算.这可能以这种形式吗?我需要将链条分开吗?
下面是握手完成后发送给WS的URL
"https://ekp.truefriend.com/COVIWeb/gate/AutoAuthentication.aspx?UserID=DP0001&BackUrl=http%3a%2f%2fgw.truefriendtest.com%2fCOVIWeb%2fApproval%2fForms%2fForm.aspx%3fmobileyn%3dY%26piid%3d96482621-6cc4-401c-a6f9-5ba6cb7ce26f%26wiid%3d425a9bc9-8607-4898-9158-ed9170da1d89%26fmpf%3dWF_A_DRAFT_PAPER01%26fmrv%3d0%26fiid%3d749526BE-B208-4987-B751-2DD0FC03F0F6%26fmid%3d24f6765d-69d1-429f-b0da-b540a064f0e2%26scid%3ddc4378f1-7edd-4d69-8fe4-5867ed32c8b9"
Run Code Online (Sandbox Code Playgroud)
它应该做的是将浏览器重定向到URL中给出的BackUrl页面.尽管存在证书问题,它仍在IE8中显示正确的结果.在PC版Chrome中,它会显示一些HTML代码.在Android中,我得到403 Forbidden错误.
HTTP/1.1 403 Forbidden ( The server denied the specified Uniform Resource Locator (URL). Contact the server administrator. )
Run Code Online (Sandbox Code Playgroud)
我使用这种方法来传输数据
try{
URL url = new URL(urlString);
HttpsURLConnection.setDefaultHostnameVerifier(new FakeHostVerifier());
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
Log.d("SSLDemo", "getAcceptedIssuers");
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
Log.d("SSLDemo", "Check Client Trusted");
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
Log.d("SSLDemo", "Check Server Trusted");
}
}
};
SSLContext sc = SSLContext.getInstance("TLS"); …
Run Code Online (Sandbox Code Playgroud)