title: In android : how to make strings inside Listview enable copying
body: <pre><code>public class mychatorderdetails extends ActionBarActivity {
      private MyApplication app;
      private String order_id;
      private String orderdate;
      private String cust_name;
      private String cust_address;
      private String cust_pincode;
      private String cust_mobile;
      private String action;
      private String UPI;
      private Button bt;
      private OrderDetailsAdapter oa;
      private ListView lv;
      private ArrayList&lt;HashMap&lt;String, String&gt;&gt; messageList;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_mychatorderdetails);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
          messageList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
          app=((MyApplication) getApplicationContext());
  
          Bundle extras = getIntent().getExtras();
  
          if(extras != null) {
              order_id = extras.getString("order_id");
              orderdate = extras.getString("orderdate");
              cust_name = extras.getString("cust_name");
              cust_address = extras.getString("cust_address");
              cust_pincode = extras.getString("cust_pincode");
              cust_mobile=extras.getString("cust_mobile");
              UPI=extras.getString("UPI");
              action=extras.getString("action"); //setaccepted, setdelivered
          }
  
          bt = (Button) findViewById(R.id.btnAction);
          switch (action)
          {
              case "setdelivered":{
                  bt.setText("Delivered");
                  break;
              }
              case "setaccepted":{
                  bt.setText("Accept");
                  break;
              }
              default:
          }
  
          try {
              String dpart = orderdate.substring(0, 10);
              String tpart = orderdate.substring(11, 19);
              orderdate = dpart.substring(8,10);
              orderdate+="/"+dpart.substring(5,7);
              orderdate+="/"+dpart.substring(0,4);
              orderdate+=" "+tpart;
          }
          catch (Exception e)
          {
              Log.d(getString(R.string.app_name), e.getMessage());
          }
          HashMap&lt;String, String&gt; row = new HashMap&lt;String, String&gt;();
          row.put("type", "text");
          row.put("details", "Order ID:"+order_id);
          messageList.add(row);
          HashMap&lt;String, String&gt; rowd = new HashMap&lt;String, String&gt;();
          rowd.put("type", "text");
          rowd.put("details", "Order Date:"+orderdate);
          messageList.add(rowd);
          HashMap&lt;String, String&gt; row1 = new HashMap&lt;String, String&gt;();
          row1.put("type", "text");
          row1.put("details",cust_name);
          messageList.add(row1);
          HashMap&lt;String, String&gt; row2 = new HashMap&lt;String, String&gt;();
          row2.put("type", "text");
          row2.put("details",cust_address);
          messageList.add(row2);
          HashMap&lt;String, String&gt; row3 = new HashMap&lt;String, String&gt;();
          row3.put("type", "text");
          row3.put("details","Pin:"+cust_pincode);
          messageList.add(row3);
          HashMap&lt;String, String&gt; row4 = new HashMap&lt;String, String&gt;();
          row4.put("type", "text");
          row4.put("details","Mob:"+cust_mobile);
          messageList.add(row4);
          HashMap&lt;String, String&gt; row5 = new HashMap&lt;String, String&gt;();
          row5.put("type", "text");
          row5.put("details","UPI:"+UPI);
          messageList.add(row5);
          oa=new OrderDetailsAdapter(mychatorderdetails.this,messageList);
          lv = (ListView) findViewById(R.id.lstOrderDetails);
          lv.setAdapter(oa);
  
          lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                  try {
                      HashMap&lt;String, String&gt; temp = new HashMap&lt;String, String&gt;();
                      temp = messageList.get(position);
                      if(temp.get("type")=="image")
                      {
                          //Uri uri = Uri.parse(temp.get("details"));
                          showImage(temp.get("details"));
                      }
  
                  } catch (Exception e) {
                      Log.d(getString(R.string.app_name), e.getMessage());
                  }
              }
          });
  
          runOnUiThread(new Runnable() {
              @Override
              public void run() {
                      try {
                          JSONArray det = app.getMyChatOrderDetails(order_id);
                          for (int i = 0; i &lt; det.length(); i++) {
                              JSONObject cat = det.getJSONObject(i);
                              HashMap&lt;String, String&gt; row = new HashMap&lt;String, String&gt;();
                              if(!TextUtils.isEmpty(cat.getString("msg_image").toString()))
                              {
                                  row.put("type", "image");
                                  row.put("details",cat.getString("msg_image").toString());
                              }
                              else
                              {
                                  row.put("type", "text");
                                  String mfv=cat.getString("msg_for_vendor").toString();
                                  if(mfv.equals("1"))
                                  {
                                      row.put("details","Customer: "+cat.getString("msg_text").toString());
                                  }
                                  else{
                                      row.put("details","Me: "+cat.getString("msg_text").toString());
                                  }
  
                              }
                              messageList.add(row);
                          }
  
                          oa.notifyDataSetChanged();
  
                      } catch (JSONException e) {
                          Log.d(getString(R.string.app_name), e.getMessage());
                      } catch (Exception e) { //connection timeout
                          Log.d(getString(R.string.app_name), e.getMessage());
                          Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
                      }
              }
          });
      }
  
      public void showImage(String imageUri) {
          Dialog builder = new Dialog(this);
          builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
          builder.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
          builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
              @Override
              public void onDismiss(DialogInterface dialogInterface) {
                  //nothing;
              }
          });
          try {
              ImageView imageView = new ImageView(this);
              Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new URL(imageUri).getContent());
              if (bitmap != null) {
                  imageView.setImageBitmap(bitmap);
                  LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(450, 400);
                  imageView.setLayoutParams(layoutParams);
                  imageView.setVisibility(View.VISIBLE);
                  builder.addContentView(imageView, new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
                  builder.show();
              }
          }
          catch (Exception e)
          {
              Log.d(getString(R.string.app_name), e.getMessage());
          }
      }
  
      public void doAction(View v)
      {
          switch (action)
          {
              case "setdelivered":{
                  if(app.setOrderDelivered(order_id)) {
                      Toast.makeText(this,"Order marked as delivered...",Toast.LENGTH_LONG).show();
                      bt.setVisibility(View.INVISIBLE);
                  }
                  break;
              }
              case "setaccepted":{
                  if(app.acceptChatOrder(order_id)){
                      Toast.makeText(this,"Order accepted...",Toast.LENGTH_LONG).show();
                      bt.setVisibility(View.INVISIBLE);
                  }
                  break;
              }
              default:
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_mychatorderdetails, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          Intent intent;
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_logout) {
              app = ((MyApplication) getApplicationContext());
              app.logOut();
              intent = new Intent(mychatorderdetails.this, LoginActivity.class);
              intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
              mychatorderdetails.this.startActivity(intent);
          }
          mychatorderdetails.this.finish();
  
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p>Following is the code to display my List ITEMS. I wanted my 5th row item i.e UPI to be enabled copying when long pressed on it. How do I do this? Please edit my code for the same to happen.</p>