上从左侧到右侧手指触摸滑动图像(图像从URL)(on finger touch slide imag

2019-10-23 02:48发布

我想滑动或从左向右移动图像。 我尝试了一下,但没有这样做,我使用的代码如下我检索图片的URL从parse.com我从我通过图像的INT位置和URL到我的第二个活动的第一项活动

  @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);
            }
        });
    }
}

在我的第二个活动,我成功地加载在imageview的图像,但不知道如何从左至右从手指触摸加载图像? 在这里,我不知道如何使用int位置和URL从以前的活动加载下一个图像。这里是我的第二个活动代码请帮助

 @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();
        }
    }
}
文章来源: on finger touch slide image from left to right (Image from URL)