Android, How to add title (a custom view) into each image item of Gallery (from gallery adapter)?
By : Suzana Sharma
Date : March 29 2020, 07:55 AM
seems to work fine In your getView(), instead of creating the ImageView on the fly, you can inflate a layout that has both an ImageView and a TextView, which you can then fill in appropriately: code :
View container = inflater.inflate(R.layout.the_layout, parent, false);
ImageView image = ll.findViewById(R.id.image);
String imageUrl = imageURLs.get(position);
imageLoader.displayImage(imageUrl, imageView, options);
TextView text = ll.findViewById(R.id.text);
text.setText("whatever");
|
Advanced Custom Fields + Gallery Field - Show First Image from the Gallery
By : Matthew Pesonen
Date : March 29 2020, 07:55 AM
will help you I’m trying to show only one image from my gallery field as a thumbnail and when the viewer clicks it a fancybox slideshow pops up. , I changed the code to this; code :
<?php
$images = get_field('gallery');
$image_1 = $images[0];
?>
<img src="<?php echo $image_1[url]; ?>" />
|
How to delete image from my Custom gallery and then Refresh the gallery
By : Dzulfan Fadli
Date : March 29 2020, 07:55 AM
wish of those help before calling notifyDataSetChanged(); You should remove Deleted image from thumbnails you need a method in your Custom Adapter to do that code :
public void RemoveThumbnail(int position)
{
this.thumbnails.remove(position);
//notifyDataSetChanged() can be called in this method or after
//calling this method in MainActivity
notifyDataSetChanged();
}
public void RemoveThumbnail(int position)
{
Bitmap[] temp = new Bitmap[thumbnails.length - 1];
int tempIndex = 0;
for (int i = 0 ; i < thumbnails.lenght ; i++)
{
if(i != position)
temp[tempIndex ++] = thumbnails[i];
}
thumbnails = temp;
//notifyDataSetChanged() can be called in this method or after
//calling this method in MainActivity
notifyDataSetChanged();
}
|
Display all post image gallery using the shortcode [gallery]
By : Shahroxe khan
Date : March 29 2020, 07:55 AM
seems to work fine I found the solution, so I share this with you. Maybe someone will be interested by that. I modified the following code : code :
$post_content = $post->post_content;
preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);
$array_id = explode(",", $ids[1]);
<?php
global $post;
$post_content = $post->post_content;
preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);
$images_id = explode(",", $ids[1]);
echo do_shortcode('[gallery type="slideshow" ids="'. implode(',', array_slice($images_id, 0, 3)).' ,"]');
?>
|
How can I import an image from gallery and replace the one that in image view?
By : Pedro Martins
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Make your button call the activity implement here with startActivityForResult: https://www.youtube.com/watch?v=w06OnGwhh4I&feature=youtu.beThis activity pick image from camera, gallery, google drive, etc. Crop and rotate the image to. Code Java: code :
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Toast;
import com.example.android.controledevendas.R;
import com.theartofdev.edmodo.cropper.CropImage;
import com.theartofdev.edmodo.cropper.CropImageView;
public class Image_Cropper_Activity extends AppCompatActivity {
private ImageButton btn_browse;
private ImageButton btn_reset;
private ImageView imageView;
private Uri uriPass = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image__cropper_);
btn_browse = findViewById(R.id.image_cropper_btn_add_picture);
btn_reset = findViewById(R.id.image_cropper_btn_reset);
imageView = findViewById(R.id.cropper_image);
btn_browse.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CropImage.startPickImageActivity(Image_Cropper_Activity.this);
}
});
btn_reset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imageView.setImageBitmap(null);
uriPass = null;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.add_cliente_fornecedor, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case (android.R.id.home):
setResult(RESULT_OK);
finish();
return true;
case (R.id.save_client_fornecedor):
saveImage();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if(requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK){
Uri imageUri = CropImage.getPickImageResultUri(this, data);
if(CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)){
}
else {
startCrop(imageUri);
}
}
if(requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE){
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if(resultCode == RESULT_OK){
imageView.setImageURI(result.getUri());
uriPass = result.getUri();
//Toast.makeText(this, "Imagem Atualizada Com Sucesso!", Toast.LENGTH_SHORT).show();
}
}
}
private void startCrop(Uri imageUri) {
CropImage.activity(imageUri).setGuidelines(CropImageView.Guidelines.ON).setMultiTouchEnabled(true).start(this);
}
private void saveImage() {
if (uriPass==null){
Toast.makeText(this, "Por favor, insira uma imagem.", Toast.LENGTH_SHORT).show();
return;
}
Intent dataForAddEditScreen = new Intent();
dataForAddEditScreen.setData(uriPass);
setResult(RESULT_OK, dataForAddEditScreen);
finish();
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
android:gravity="center"
android:padding="10dp"
tools:context=".Activities.Image_Cropper_Activity">
<ImageView
android:id="@+id/cropper_image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:padding="20dp">
<ImageButton
android:id="@+id/image_cropper_btn_add_picture"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/bg_round"
app:srcCompat="@drawable/ic_image_sample_50x50_white" />
<Space
android:layout_width="20dp"
android:layout_height="wrap_content" />
<Space
android:layout_width="20dp"
android:layout_height="wrap_content" />
<ImageButton
android:id="@+id/image_cropper_btn_reset"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/bg_round"
app:srcCompat="@drawable/ic_refresh_50x50_white" />
</LinearLayout>
</LinearLayout>
private ImageView imageProduto;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add__edit__produto_);
imageProduto = findViewById(R.id.image_produto_detail);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == Constantes.REQUEST_CODE_ADD_PICTURE && resultCode == RESULT_OK && data!= null){
Uri imageUri = data.getData();
imageProduto.setImageURI(imageUri);
Toast.makeText(this, "Image Update Successfully!", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(this, "Image Not Updated!", Toast.LENGTH_SHORT).show();
}
}
|