我正在使用viewpageradapter在viewpager上使用一个布局,可容纳5个孩子(5个计数)。在该布局中,我具有EditText视图,一切正常,但我需要一些功能,例如当我在viewpager中更改/编辑其中一个子项中的值时,然后在滚动任何更改/引用的值/文本时也必须在其余子项上附加值。我得到的意思是,如果我在第0个位置进行了编辑,并且更改了第1个位置,则它(已编辑的值)在第1个位置中可见,但在剩余位置中可见,但在下一个位置中不可见
enter code here private void createView(View view, final int position, final View media_images_layout) {
final EditText text_width = (EditText) view.findViewById(R.id.inline_with);
final EditText text_height = (EditText) view.findViewById(R.id.inline_heigth);
final EditText inline_width = (EditText) view.findViewById(R.id.editTxt_numberwidth);
final EditText inline_heigth = (EditText) view.findViewById(R.id.editTxt_number);
;
final LinearLayout width_lyt = (LinearLayout) view.findViewById(R.id.width_lyt);
final LinearLayout hight_lyt = (LinearLayout) view.findViewById(R.id.hight_lyt);
ImageView setImage = (ImageView) view.findViewById(R.id.setImage);
final RecyclerView grid_recycler = (RecyclerView) view.findViewById(R.id.grid_recycler);
final TextView noresults = (TextView) view.findViewById(R.id.noresults);
noresults.setVisibility(GONE);
final ProgressBar cloud_progress = (ProgressBar) view.findViewById(R.id.line_progress);
final ProgressBar cloud_progress2 = (ProgressBar) view.findViewById(R.id.line_progress2);
final ImageView select_id = (ImageView) view.findViewById(R.id.select_id);
final EditText et_Comment=(EditText)view.findViewById(R.id.comment);
final TextView comment_title=(TextView)view.findViewById(R.id.comment_title);
final RelativeLayout params=(RelativeLayout)view.findViewById(R.id.params);
final RelativeLayout pickImage=(RelativeLayout)view.findViewById(R.id.pickImage);
final RelativeLayout pickImage2=(RelativeLayout)view.findViewById(R.id.pickImage2);
if(viewtype.equals("textimageinline")) {
et_Comment.setVisibility(GONE);
comment_title.setVisibility(GONE);
params.setVisibility(VISIBLE);
pickImage.setVisibility(VISIBLE);
pickImage2.setVisibility(GONE);
inline_heigth.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
setInline_img_height(inline_heigth.getText().toString());
setEditorImage(path,false);
}
((NooorActivity)mContext).showKeybooard();
return false;
}
});
inline_heigth.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
setInline_img_height(editable.toString());
}
});
et_Comment.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
if(!et_Comment.equals("") && viewtype.equals("textimage")) {
setEditorImage(path,true);
//webView.addWebViewAction("updateTextMediaProperties("+prepareTextMediaObject(path,et_Comment.getText().toString(),text_width.getText().toString(),text_height.getText().toString())+")");
// webView.loadUrl("javascript:addImageComment(\"" + et_Comment.getText().toString() + "\")");
}
}
return false;
}
});
et_Comment.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
setEdit_comment(editable.toString());
}
});
setImage.setTag(position);
select_id.setTag(position);
inline_heigth.setTag(position);
inline_width.setTag(position);
text_height.setTag(position);
text_width.setTag(position);
// RelativeLayout pickImage = (RelativeLayout) view.findViewById(R.id.pickImage);
pickImage.setGravity(Gravity.CENTER);
pickImage.setVerticalGravity(Gravity.CENTER);
select_id.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
donotsavePath=false;
switch (viewtype) {
case "textimage":
case "textimageinline":
case "mediaimage":
case "background_image":
case "mindmap":
switch ((Integer) view.getTag()) {
case 1:
NooorApplication.getInstance().setFromLeftmenu(true);
PhotoFromGallery();
break;
case 0:
media_images_layout.setVisibility(GONE);
grid_recycler.setLayoutManager(new GridLayoutManager(activity, 4));
List<String> myList= new LinkedList<>();
File file = new File( AllConstantVariables.APPLICATION_MEDIA);
File list[] = file.listFiles();
if(list!=null) {
grid_recycler.setVisibility(VISIBLE);
for (int i = 0; i < list.length; i++) {
if (list[i].getName().toLowerCase(Locale.getDefault()).endsWith(".png")) {
myList.add(list[i].getName());
}
}
donotsavePath=true;
String[] list2 = myList.toArray(new String[myList.size()]);
if (list2 != null && list2.length > 0) {
MyRecyclerViewAdapter grid_recycleradapter = new MyRecyclerViewAdapter(activity, list2,
cloudImages, new OnImagesListener() {
@Override
public void imageslistener(String image, Bitmap result) {
setImage( /*AllConstantVariables.BOOKDOWNLOADIGPATH+"/book/"+ pagesdata.getStoreid() + "/thumbnails/"+*/image, "mygallery", result, pageContent, false);
}
});
grid_recycler.setAdapter(grid_recycleradapter);
} else {
grid_recycler.setVisibility(GONE);
noresults.setVisibility(VISIBLE);
noresults.setText("No MyGallery Images");
//Toast.makeText(mContext, "No MyGallry Images", Toast.LENGTH_SHORT).show();
}
}else{
grid_recycler.setVisibility(GONE);
noresults.setVisibility(VISIBLE);
noresults.setText("No MyGallery Images");
//Toast.makeText(mContext, "No MyGallry Images", Toast.LENGTH_SHORT).show();
}
break;
case 2:
NooorApplication.getInstance().setFromLeftmenu(true);
editorCallBacks.captureImage();
break;
case 4:
if(cloudImages.isEmpty()){
select_id.setVisibility(GONE);
getCloudFiles("image/",cloud_progress2,new MyDriveFiles() {
@Override
public void myDriveFiles(List<com.google.api.services.drive.model.File> myDriveFiles, com.google.api.services.drive.model.File myDriveFile, boolean isMyDrive) {
couchbaseMain.setAllDriveFiles(myDriveFiles);
cloudImages = couchbaseMain.openFiles("image/");
setREcyclerView(media_images_layout,grid_recycler,"cloud",false,noresults);
Toast.makeText(mContext,cloudImages.size()+"",Toast.LENGTH_SHORT).show();
}
});
}else {
cloudImages.clear();
cloudImages = couchbaseMain.openFiles("image/");
setREcyclerView(media_images_layout,grid_recycler,"cloud",false, noresults);
}
break;
case 3:
media_images_layout.setVisibility(GONE);
MediaView.setVisibility(GONE);
serach_layout.setVisibility(VISIBLE);
back_media.setVisibility(VISIBLE);
media.setVisibility(VISIBLE);
media.setText("Images by Google");
media.setTypeface(media.getTypeface(), Typeface.BOLD);
/*MediaFromBrowser browser2 = new MediaFromBrowser(activity);
browser2.getImageDialog();*/
break;
}
break;
case "mediavideo":
switch ((Integer) view.getTag()) {
case 1:
NooorApplication.getInstance().setFromLeftmenu(true);
editorCallBacks.VideoFromGallery();
break;
case 0:
media_images_layout.setVisibility(GONE);
grid_recycler.setVisibility(VISIBLE);
grid_recycler.setLayoutManager(new GridLayoutManager(activity, 4));
File thumbnailssrcDir = new File( AllConstantVariables.APPLICATION_MEDIA);
// String[] list2 = thumbnailssrcDir.list();
List<String> myList= new LinkedList<>();
File file = new File( AllConstantVariables.APPLICATION_MEDIA);
File list[] = file.listFiles();
if(list!=null) {
for (int i = 0; i < list.length; i++) {
if(list[i].getName().toLowerCase(Locale.getDefault()).endsWith(".mp4")){
myList.add(list[i].getName());
}
}
donotsavePath=true;
String [] list2 = myList.toArray(new String[myList.size()]);
if(list2!=null&&list2.length>0) {
MyRecyclerViewAdapter grid_recycleradapter = new MyRecyclerViewAdapter(activity, list2,
cloudImages, new OnImagesListener() {
@Override
public void imageslistener(String image, Bitmap result) {
setImage( /*AllConstantVariables.BOOKDOWNLOADIGPATH+"/book/"+ pagesdata.getStoreid() + "/thumbnails/"+*/image,"mygallery", result, pageContent, true);
}
});
grid_recycler.setAdapter(grid_recycleradapter);
}else {
grid_recycler.setVisibility(GONE);
noresults.setVisibility(VISIBLE);
noresults.setText("No MyGallery Videos");
//Toast.makeText(mContext, "No MyGallry Images", Toast.LENGTH_SHORT).show();
}
}else {
grid_recycler.setVisibility(GONE);
noresults.setVisibility(VISIBLE);
noresults.setText("No MyGallery Videos");
//Toast.makeText(mContext, "No MyGallry Images", Toast.LENGTH_SHORT).show();
}
break;
case 2:
NooorApplication.getInstance().setFromLeftmenu(true);
editorCallBacks.recordVideo();
break;
case 4:
if(cloudImages.isEmpty()){
select_id.setVisibility(GONE);
getCloudFiles("video/", cloud_progress2, new MyDriveFiles() {
@Override
public void myDriveFiles(List<com.google.api.services.drive.model.File> myDriveFiles, com.google.api.services.drive.model.File myDriveFile, boolean isMyDrive) {
couchbaseMain.setAllDriveFiles(myDriveFiles);
cloudImages = couchbaseMain.openFiles("video/");
setREcyclerView(media_images_layout, grid_recycler, "cloud", true, noresults);
Toast.makeText(mContext, cloudImages.size() + "", Toast.LENGTH_SHORT).show();
}
});
}
else {
cloudImages.clear();
cloudImages = couchbaseMain.openFiles("video/");
setREcyclerView(media_images_layout, grid_recycler, "cloud", true, noresults);
}
break;
case 3:
media_images_layout.setVisibility(GONE);
MediaView.setVisibility(GONE);
serach_layout.setVisibility(VISIBLE);
back_media.setVisibility(VISIBLE);
media.setVisibility(VISIBLE);
media.setText("Vedios by Google");
/* MediaFromBrowser browser2 = new MediaFromBrowser(activity);
browser2.getVedioDialog();*/
break;
}
break;
case "mediaaudio":
switch ((Integer) view.getTag()) {
case 0:
NooorApplication.getInstance().setFromLeftmenu(true);
//activity.PhotoFromGallery();
editorCallBacks.selectAudioFile();
break;
case 1:
if(cloudImages.isEmpty()){
select_id.setVisibility(GONE);
getCloudFiles("audio/",cloud_progress,new MyDriveFiles() {
@Override
public void myDriveFiles(List<com.google.api.services.drive.model.File> myDriveFiles, com.google.api.services.drive.model.File myDriveFile, boolean isMyDrive) {
couchbaseMain.setAllDriveFiles(myDriveFiles);
cloudImages = couchbaseMain.openFiles("audio/");
setREcyc hight_lyt.setBackground(getResources().getDrawable(R.drawable.text_style_bg_normal));
}
});
et_Comment.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
if (!b)
et_Comment.setBackground(getResources().getDrawable(R.drawable.text_style_bg_md));
else
et_Comment.setBackground(getResources().getDrawable(R.drawable.text_style_bg_normal));
}
});
if (getImg_width() != null)
text_width.setText(getImg_width());
if (getImg_height() != null)
text_height.setText(getImg_height());
if (getInline_img_width() != null)
inline_width.setText(getInline_img_width());
if (getInline_img_height() != null)
inline_heigth.setText(getInline_img_height());
if (getEdit_comment() != null)
et_Comment.setText(getEdit_comment());
}