on finger touch slide image from left to right (Image from URL)

一笑奈何 提交于 2019-12-24 18:15:31

问题


I want to slide or move a image from left to right. I tried a bit but failed to do so i used the codes as below I retrieve Images from URL from parse.com My first Activity from which i pass int position and URL of the image to my second activity

  @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listview_main);
    Intent i = getIntent();
    // Get the name
    name = i.getStringExtra("name").replace(" ", "_");
    position = i.getExtras().getInt("id");
    Log.d("Tag Name", position+name);
    // Execute RemoteDataTask AsyncTask
    new RemoteDataTask().execute();
}
// RemoteDataTask AsyncTask
private class RemoteDataTask extends AsyncTask<Void, Void, Void> {
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        mProgressDialog = new ProgressDialog(MyFirstActivity.this);
        mProgressDialog.setTitle("Listing...");
        mProgressDialog.setMessage("Loading...");
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.show();
    }
    @Override
    protected Void doInBackground(Void... params) {
    // Locate the class in Parse.com
        ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(
                name);
        query.orderByAscending("sort");
        try {
            ob = query.find();
        } catch (ParseException e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return null;
    }
    @Override
    protected void onPostExecute(Void result) {
        listview = (ListView) findViewById(R.id.listview);
        adapter = new ArrayAdapter<String>(MyFirstActivity.this,
                R.layout.listview_item,R.id.text);
     // Retrieve object Parse.com database
        for (ParseObject country : ob) {
            adapter.add((String) country.get("name"));
            country.get("Murl");
        }
        listview.setAdapter(adapter);
        mProgressDialog.dismiss();
        listview.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                                    int position, long id) {
                Intent i = new Intent(MyFirstActivity.this,
                        SecondActivity.class);
            // Pass data "name" followed by the position
                i.putExtra("Murl", ob.get(position).getString("Murl")
                        .toString());
                i.putExtra("id", position);
            // Open SecondActivity.java Activity
                startActivity(i);
            }
        });
    }
}

In my second Activity I am successful to load images in imageview but dont know how to load image from on finger touch from left to right?? Here I dont know how to use int position and URL to load next image from previous Activity.. Here is my second Activity code PLEASE HELP

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.singleitemview1);
    Intent i = getIntent();
    // Get the name
    name = i.getStringExtra("Nurl");
    position = i.getExtras().getInt("id");
    Log.d("Tag Name", position + name);
    img = (TouchImageView)findViewById(R.id.imge);
    imgLoader = new ImageLoader(this);
    imgLoader.DisplayImage(name, img);
    new LoadImage().execute(name);
}
private class LoadImage extends AsyncTask<String, String, Bitmap> {
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(SingleItemView1.this);
        pDialog.setMessage("Loading Image ....");
        pDialog.show();
    }
    protected Bitmap doInBackground(String... args) {
        try {
            bitmap = BitmapFactory.decodeStream((InputStream)new URL(args[0]).getContent());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return bitmap;
    }
    protected void onPostExecute(Bitmap image) {

        if(image != null){
            img.setImageBitmap(image);
            pDialog.dismiss();
        }else{
            pDialog.dismiss();
            Toast.makeText(SecondActivity.this, "Image Does Not exist or Network Error", Toast.LENGTH_SHORT).show();
        }
    }
}

来源:https://stackoverflow.com/questions/30267446/on-finger-touch-slide-image-from-left-to-right-image-from-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!