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" />