From a1b98df15b9d7450e40f11d8651db16cbc1d6dc0 Mon Sep 17 00:00:00 2001 From: else <18872260424@163.com> Date: Thu, 20 Sep 2018 12:43:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E5=B8=A6imageView=20show=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95=20=E6=B7=BB=E5=8A=A0=E5=88=9D=E5=A7=8Bpos=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ch/ielse/demo/p02/Fragment1.java | 14 ++++- app/src/main/res/layout/fragment.xml | 11 +++- .../ielse/imagewatcher/ImageWatcher.java | 52 ++++++++++--------- .../imagewatcher/ImageWatcherHelper.java | 4 +- 4 files changed, 52 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/ch/ielse/demo/p02/Fragment1.java b/app/src/main/java/ch/ielse/demo/p02/Fragment1.java index 7f5a025..a876d7f 100644 --- a/app/src/main/java/ch/ielse/demo/p02/Fragment1.java +++ b/app/src/main/java/ch/ielse/demo/p02/Fragment1.java @@ -10,10 +10,12 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; +import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; @@ -37,12 +39,14 @@ public class Fragment1 extends Fragment { private ImageWatcherHelper iwHelper; private final List pictureList = new ArrayList<>(); private TextView vPictureUris; + private EditText vIdx; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View itemView = inflater.inflate(R.layout.fragment, container, false); + vIdx = itemView.findViewById(R.id.vIdx); vPictureUris = itemView.findViewById(R.id.vPictureUris); View vAddLocal = itemView.findViewById(R.id.vAddLocal); @@ -58,7 +62,15 @@ public void onClick(View v) { @Override public void onClick(View v) { if (iwHelper != null) { - iwHelper.show(pictureList); + int currIdx = 0; + try { + if (!TextUtils.isEmpty(vIdx.getText())) { + currIdx = Integer.parseInt(vIdx.getText().toString()); + } + } catch (Exception e) { + e.printStackTrace(); + } + iwHelper.show(pictureList, currIdx); } } }); diff --git a/app/src/main/res/layout/fragment.xml b/app/src/main/res/layout/fragment.xml index 0f61d78..be75d70 100644 --- a/app/src/main/res/layout/fragment.xml +++ b/app/src/main/res/layout/fragment.xml @@ -14,8 +14,8 @@ + android:text="这里开始是fragment区域" + android:textColor="#f00" />