i downloading images in an imageview from a json Server i need to open the image when clicking it and i send the position of the image to an activity that contain an imageview to Receive the sended photo but my problem is the imageView.setImageResource(list.get(ReceivedPosition)) take an intger and my list of photos from a custom obeject photos here the code
public class customfunny extends BaseAdapter {
Context c;
ArrayList<photos> sites;
public customfunny(Context c, ArrayList<photos> sites)
{
this.c = c;
this.sites = sites;
}
#Override
public int getCount() {
return sites.size();
}
#Override
public Object getItem(int i) {
return sites.get(i);
}
#Override
public long getItemId(int i) {
return i;
}
#Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view==null)
{
view = LayoutInflater.from(c).inflate(R.layout.funnyinflate,viewGroup,false);
}
ImageView imageView = (ImageView) view.findViewById(R.id.imageView1);
photos site = (photos) this.getItem(i);
Picasso.with(c).load(site.getImage()).into(imageView);
return view;
}
}
pulbic class Funny extends AppCompactActivity{String url = "http://javawy.fulba.com/yphotos.php";
ProgressDialog dialog;
ArrayList<photos> list;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_funny);
final GridView gridView = (GridView) findViewById(R.id.gridview);
StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
JSONObject object = new JSONObject(response);
JSONArray jsonArray = object.getJSONArray("photos");
list = new ArrayList<>();
for (int i = 0;i<jsonArray.length();i++)
{
JSONObject object1 = jsonArray.getJSONObject(i);
String pw = object1.getString("image");
photos posts = new photos(pw);
list.add(posts);
}
customfunny adapter = new customfunny(Funny.this,list);
gridView.setAdapter(adapter);
dialog.dismiss();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
dialog.dismiss();
Toast.makeText(Funny.this,"error",Toast.LENGTH_LONG).show();
}
});
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Intent intent = new Intent(Funny.this,SelectedImage.class);
intent.putExtra("one",i);
}
});
dialog = new ProgressDialog(Funny.this);
dialog.setTitle("downloading");
dialog.setMessage("wait......");
dialog.show();
Volley.newRequestQueue(Funny.this).add(stringRequest);
}}
public class SelectedImage extends AppCompactActivity{ #Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_selected_image);
Intent i = getIntent();
int position = i.getExtras().getInt("one");
ImageView imageView = (ImageView) findViewById(R.id.result);
imageView.setImageResource(new Funny().list.get(position));//compiler error
}}
Just pas the actual URL in the intent, and then use Picasa to download the image into view. Picasa internally has already cached the image. There is no reason you are recreating the Funny Class and Adapter.
Related
I get data in JSON from API, and there are id and url. Now, i need to create a button "Add to favorites" for each image that i display. When i try to set adapter.setListener(this);, i get an error, because i can't use string format.
How can i resolve this problem? I spend 5 hours on this, and can't resolve it :(
MainActivity:
protected void onCreate(Bundle savedInstanceState) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = findViewById(R.id.listItem);
favorites = findViewById(R.id.buttonFav);
catDetailsArrayList = new ArrayList<>();
myAdapter = new MyAdapter(MainActivity.this ,catDetailsArrayList);
searchbtn = findViewById(R.id.buttonSearch);
searchbtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
catDetailsArrayList.clear();
myAdapter.notifyDataSetChanged();
displayCats();
}
});
});
}
private void displayCats() {
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try{
JSONArray jsonArray = new JSONArray(response);
for(int i=0; i<jsonArray.length(); i++){
JSONObject jsonObject1 = jsonArray.getJSONObject(i);
String jsonCatUrl2 = jsonObject1.getString("url");
String jsonCatId2 = jsonObject1.getString("id");
CatDetails catDetails = new CatDetails();
catDetails.setUrl(jsonCatUrl2);
catDetails.setId(jsonCatId2);
catDetailsArrayList.add(catDetails);
}
listView.setAdapter(myAdapter);
myAdapter.notifyDataSetChanged();
} catch(JSONException e){
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(),error.getMessage(),Toast.LENGTH_LONG).show();
}
});
requestQueue.add(stringRequest);
}
MyAdapter:
public class MyAdapter extends BaseAdapter {
public Activity activity;
public ArrayList<CatDetails> catDetailsArrayList;
public LayoutInflater inflater;
Button btn;
TextView idnr;
public MyAdapter(Activity activity, ArrayList<CatDetails> catDetailsArrayList) {
this.activity = activity;
this.catDetailsArrayList = catDetailsArrayList;
}
#Override
public Object getItem(int position) {
return catDetailsArrayList.get(position);
}
#Override
public long getItemId(int position) {
return (long)position;
}
#Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
if (inflater == null) {
inflater = this.activity.getLayoutInflater();
}
if (convertView == null) {
convertView = inflater.inflate(R.layout.list_item, null);
}
ImageView imageView = convertView.findViewById(R.id.ImageView);
final CatDetails catDetails = this.catDetailsArrayList.get(position);
Picasso.get().load(catDetails.getUrl()).into(imageView);
idnr =convertView.findViewById(R.id.textView);
btn = convertView.findViewById(R.id.buttonFav);
final String id = catDetails.getId();
idnr.setText(catDetails.getId());
return convertView;
}
#Override
public int getCount() {
return this.catDetailsArrayList.size();
}
I display the id that i receive from server for each item, it's ok, but i don't know how to set the button "add to favorites" to works fine. It must receive item id (that i received from server) as a param, but id is in string format.
final String id = catDetails.getId();
change it to
final String id = Integer.toString(catDetails.getId());
I got the data from server to list view successfully with some online help. What I wanted is to go to another activity and get the "id" of the list view item and display it.
I have been trying a lot to figure this out but haven't succeeded.
My mainactivity.java file
public class MainActivity extends AppCompatActivity {
ListView listView;
Button button;
// Server Http URL
String HTTP_URL = "http://192.168.100.48/listview/index.php";
// String to hold complete JSON response object.
String FinalJSonObject ;
ProgressBar progressBar;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Assign ID's to ListView.
listView = (ListView) findViewById(R.id.listView1);
button = (Button)findViewById(R.id.button);
progressBar = (ProgressBar)findViewById(R.id.ProgressBar1);
// Adding click listener to button.
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
//Showing progress bar just after button click.
progressBar.setVisibility(View.VISIBLE);
// Creating StringRequest and set the JSON server URL in here.
StringRequest stringRequest = new StringRequest(HTTP_URL,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
// After done Loading store JSON response in FinalJSonObject string variable.
FinalJSonObject = response ;
// Calling method to parse JSON object.
new ParseJSonDataClass(MainActivity.this).execute();
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
// Showing error message if something goes wrong.
Toast.makeText(MainActivity.this,error.getMessage(),Toast.LENGTH_LONG).show();
}
});
// Creating String Request Object.
RequestQueue requestQueue = Volley.newRequestQueue(MainActivity.this);
// Passing String request into RequestQueue.
requestQueue.add(stringRequest);
}
});
}
// Creating method to parse JSON object.
private class ParseJSonDataClass extends AsyncTask<Void, Void, Void> {
public Context context;
// Creating List of Subject class.
List<Subject> CustomSubjectNamesList;
public ParseJSonDataClass(Context context) {
this.context = context;
}
#Override
protected void onPreExecute() {
super.onPreExecute();
}
#Override
protected Void doInBackground(Void... arg0) {
try {
// Checking whether FinalJSonObject is not equals to null.
if (FinalJSonObject != null) {
// Creating and setting up JSON array as null.
JSONArray jsonArray = null;
try {
// Adding JSON response object into JSON array.
jsonArray = new JSONArray(FinalJSonObject);
// Creating JSON Object.
JSONObject jsonObject;
// Creating Subject class object.
Subject subject;
// Defining CustomSubjectNamesList AS Array List.
CustomSubjectNamesList = new ArrayList<Subject>();
for (int i = 0; i < jsonArray.length(); i++) {
subject = new Subject();
jsonObject = jsonArray.getJSONObject(i);
//Storing ID into subject list.
subject.Subject_ID = jsonObject.getString("id");
//Storing Subject name in subject list.
subject.Subject_Name = jsonObject.getString("subject_Name");
// Adding subject list object into CustomSubjectNamesList.
CustomSubjectNamesList.add(subject);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
#Override
protected void onPostExecute(Void result)
{
// After all done loading set complete CustomSubjectNamesList with application context to ListView adapter.
ListViewAdapter adapter = new ListViewAdapter(CustomSubjectNamesList, context);
// Setting up all data into ListView.
listView.setAdapter(adapter);
// Hiding progress bar after all JSON loading done.
progressBar.setVisibility(View.GONE);
}
}
}
My Listviewadapter.java file
public class ListViewAdapter extends BaseAdapter
{
Context context;
List<Subject> TempSubjectList;
public ListViewAdapter(List<Subject> listValue, Context context)
{
this.context = context;
this.TempSubjectList = listValue;
}
#Override
public int getCount()
{
return this.TempSubjectList.size();
}
#Override
public Object getItem(int position)
{
return this.TempSubjectList.get(position);
}
#Override
public long getItemId(int position)
{
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent)
{
ViewItem viewItem = null;
if(convertView == null)
{
viewItem = new ViewItem();
LayoutInflater layoutInfiater = (LayoutInflater)this.context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = layoutInfiater.inflate(R.layout.listview_items, null);
viewItem.IdTextView = (TextView)convertView.findViewById(R.id.textviewID);
viewItem.NameTextView = (TextView)convertView.findViewById(R.id.textviewSubjectName);
convertView.setTag(viewItem);
}
else
{
viewItem = (ViewItem) convertView.getTag();
}
viewItem.IdTextView.setText(TempSubjectList.get(position).Subject_ID);
viewItem.NameTextView.setText(TempSubjectList.get(position).Subject_Name);
return convertView;
}
}
class ViewItem {
TextView IdTextView;
TextView NameTextView;
}
And of course, my subject.java file
public class Subject {
public String Subject_ID;
public String Subject_Name;
}
IMAGE - It successfully shows the data from server. But I haven't figured it out how to make what I want to do when I click the item.
So yes, that's what's taking my sleep and peace.
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long id) {
Intent intent = new Intent(MainActivity.this, AnotherActivity.class);
intent.putExtra("ID",CustomSubjectNamesList.get(position).Subject_ID);
startActivity(intent);
}
});
And From Another Activity
First, get the intent which has started your activity using the getIntent() method:
Intent intent = getIntent();
If your extra data is represented as strings, then you can use intent.getStringExtra(String name) method. In your case:
Intent intent = getIntent();
String id = intent.getStringExtra("ID");
you can send a string or an integer or simply any object that implements Serializable to another activity using intent.putExtra()
listView.setOnItemClickListener(new AdapaterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long id) {
Intent intent = new Intent(MainActivity.this, AnotherActivity.class);
intent.putExtra("id",CustomSubjectNamesList.get(position).Subject_ID;
startActivity(intent);
}
});
And in your new activity receive that info you just sent using getIntent.getIntExtra("id") or getIntent.getStringExtra(). or using it's other methods based on what you have sent.
I am sending the values from Activity to the Adapter and it's working. but sometimes it's run perfectly but sometimes it gives not responding error in the emulator. don't know why it happening
I am showing the images grid view which is fetched from MYSQL server.
MainActivity:
public class MainActivity extends AppCompatActivity {
public static final String URL_LOGIN= "http://10.0.2.2/e-stitch/fatchimg.php?apicall=shirt";
public static String[] mThumbIds;
ImageAdapter imageAdapter = new ImageAdapter (MainActivity.this);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
userLogin();
final GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(imageAdapter);
gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
//Intent i = new Intent(getApplicationContext(), FullImageActivity.class);
//i.putExtra("id", position);
//startActivity(i);
}
});
}
public void userLogin() {
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL_LOGIN,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
JSONObject obj = new JSONObject(response);
if (!obj.getBoolean("error")) {
Toast.makeText(getApplicationContext(), obj.getString("message"), Toast.LENGTH_SHORT).show();
JSONArray arrJson = obj.getJSONArray("user");
mThumbIds = new String[arrJson.length()];
for(int i = 0; i < arrJson.length(); i++) {
mThumbIds[i] = arrJson.getString(i);
}
imageAdapter.setimag(mThumbIds);
} else {
Toast.makeText(getApplicationContext(), obj.getString("message"), Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
}
}) {
#Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("shirt", "shirt");
return params;
}
};
VolleySingleton.getInstance(this).addToRequestQueue(stringRequest);
}
}
ImageAdapter:
public class ImageAdapter extends BaseAdapter {
private Context mContext;
int imageTotal=6;
public static String[] mThumbIds;
public ImageAdapter(Context c) {
mContext = c;
}
public void setimag(String[] mThumbIds){
this.mThumbIds = mThumbIds;
this.imageTotal = 6;
}
public int getCount() {
return imageTotal;
}
#Override
public String getItem(int position) {
return mThumbIds[position];
}
public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(480, 480));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}
String url = getItem(position);
Picasso.with(mContext)
.load(url)
.placeholder(R.drawable.loader)
.fit()
.centerCrop().into(imageView);
return imageView;
}
}
I built a listview that displays dynamic buttons with the name of tables in a database. When a person clicks the button it's supposed to grab the text of the button and then pass that to the next activity which would populate the information corresponding to the database table and display that text at the top of the screen. The code I've written keeps crashing when I click the button. Is there something else I need to call or does this code not work with a button?
public class UserArea extends AppCompatActivity {
SectionListAdapter sectionListAdapter;
ListView listView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_area);
TextView tvWelcomeMsg = (TextView) findViewById(R.id.tvWelcome);
/**Get Sections and Display as buttons*/
listView = (ListView) findViewById(R.id.lvSections);
sectionListAdapter = new SectionListAdapter(this, R.layout.section_layout);
listView.setAdapter(sectionListAdapter);
Response.Listener<String> responseListener = new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
/** If data successfully gathered*/
if (success) {
JSONArray jsonArray= jsonResponse.getJSONArray("Flights");
int count = 0;
String flight;
while(count<jsonArray.length()) {
JSONObject SL = jsonArray.getJSONObject(count);
flight = SL.getString("Flight");
SectionList sl = new SectionList(flight);
sectionListAdapter.add(sl);
count++;
}
}
/** If data is not gathered*/
else {
AlertDialog.Builder builder = new AlertDialog.Builder(UserArea.this);
builder.setMessage("Failed to connect")
.setNegativeButton("Retry", null)
.create()
.show();
}
}
/** if any other response is received*/
catch (JSONException e) {
e.printStackTrace();
}
}
};
/**Creates Request to get the data*/
GetSectionRequest getSections = new GetSectionRequest(responseListener);
/**Creates a queue to run the code*/
RequestQueue queue = Volley.newRequestQueue(UserArea.this);
queue.add(getSections);
/**End*/
/**Creates onclicklistener to pass clicked section name*/
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
Intent intent = new Intent (UserArea.this, Personnel.class);
intent.putExtra("section", listView.getItemAtPosition(i).toString());
UserArea.this.startActivity(intent);
}
});
SectionListAdapter
public class SectionListAdapter extends ArrayAdapter {
List list = new ArrayList();
public SectionListAdapter(Context context, int resource) {
super(context, resource);
}
public void add(SectionList object) {
super.add(object);
list.add(object);
}
#Override
public int getCount() {
return list.size();
}
#Override
public Object getItem(int position) {
return list.get(position);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View row;
row = convertView;
SectionListAdapter.SectionListHolder sectionListHolder;
if (row == null){
LayoutInflater layoutInflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = layoutInflater.inflate(R.layout.section_layout, parent, false);
sectionListHolder = new SectionListAdapter.SectionListHolder();
sectionListHolder.bSection = row.findViewById(R.id.bSectionName);
}else{
sectionListHolder = (SectionListAdapter.SectionListHolder)row.getTag();
}
SectionList SectionList = (SectionList) this.getItem(position);
sectionListHolder.bSection.setText(SectionList.getFlight());
return row;
}
static class SectionListHolder{
Button bSection;
}
}
Log Cat
10-10 19:31:26.797 6595-6595/com.example.yikes.recall E/AndroidRuntime:
FATAL EXCEPTION: main
Process: com.example.yikes.recall, PID: 6595
java.lang.NullPointerException: Attempt to read from field 'android.widget.Button com.example.yikes.recall.SectionListAdapter$SectionListHolder.bSection' on a null object reference
I'm try code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ListView listView = new ListView(this);
listView.setBackgroundColor(Color.WHITE);
setContentView(listView);
final String[] activities = new String[]{"Item1", "Item2", "Item3", "Item4"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line);
listView.setAdapter(adapter);
for (String item : activities) {
adapter.add(item);
}
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String item = listView.getItemAtPosition(position).toString();
Intent intent = new Intent(MainActivity.this, SampleActivity.class);
intent.putExtra("item", item);
MainActivity.this.startActivity(intent);
}
});
}
It's working, I think
/**Creates Request to get the data*/
GetSectionRequest getSections = new GetSectionRequest(responseListener);
/**Creates a queue to run the code*/
RequestQueue queue = Volley.newRequestQueue(UserArea.this);
queue.add(getSections);
Need some time, you can add ProgressDialog when start app and dismiss when response callback. Hope it can help you!
i have images that downloaded from a server and it downloaded into grid view when i clicked an image it opened in another activity i need to swip between images when opened into the second activity what is the wrong in my code?
public class customswitcher extends PagerAdapter{
Context c;
ArrayList<photos> sites;
LayoutInflater inflater;
public customswitcher(Context c, ArrayList<photos> sites)
{
this.c = c;
this.sites = sites;
}
#Override
public int getCount() {
return 0;
}
#Override
public boolean isViewFromObject(View view, Object object) {
return view== (LinearLayout) object;
}
#Override
public Object instantiateItem(ViewGroup container, int position) {
inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.imageswitcher,container,false);
ImageView imageView = (ImageView) view.findViewById(R.id.iv);
photos photos = sites.get(position);
Picasso.with(c).load(photos.getImage()).into(imageView);
container.addView(view);
return view;
}
#Override
public void destroyItem(ViewGroup container, int position, Object object) {
super.destroyItem(container, position, object);
}
}
public class Funny extends AppCompatActivity {
MyDataBase dataBase = new MyDataBase(Funny.this);
String url = "http://javawy.fulba.com/yphotos.php";
ProgressDialog dialog;
String pw;
List<photos> list;
photos posts;
customfunny adapter;
#Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_funny);
list= dataBase.getallcontacts();
final GridView gridView = (GridView) findViewById(R.id.gridview);
StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
JSONObject object = new JSONObject(response);
JSONArray jsonArray = object.getJSONArray("photos");
list = new ArrayList<>();
for (int i = 0;i<jsonArray.length();i++)
{
JSONObject object1 = jsonArray.getJSONObject(i);
pw = object1.getString("image");
posts = new photos(pw);
dataBase.AddnewContact(posts);
list.add(posts);
}
dialog.dismiss();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
dialog.dismiss();
Toast.makeText(Funny.this,"اتصل بالانترنت لتحصل علي احيث الصور",Toast.LENGTH_LONG).show();
}
});
adapter = new customfunny(Funny.this,list);
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
photos photos = (com.example.yasser.ahlysc.photos) gridView.getItemAtPosition(i);
Intent intent = new Intent(Funny.this,SelectedImage.class);
intent.putExtra("one",photos.getImage());
startActivity(intent);
adapter.notifyDataSetChanged();
}
});
dialog = new ProgressDialog(Funny.this);
dialog.setTitle("downloading");
dialog.setMessage("جاري تحديث الصور....انتظر");
dialog.show();
Volley.newRequestQueue(Funny.this).add(stringRequest);
}
}
public class SelectedImage extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_selected_image);
Intent i = getIntent();
String s = i.getStringExtra("one");
ArrayList<photos> list = new ArrayList<>();
list.add(new photos(s));
ViewPager pager = (ViewPager) findViewById(R.id.vp);
customswitcher customswitcher = new customswitcher(SelectedImage.this,list);
pager.setAdapter(customswitcher);
}
}