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<HashMap<String, String>> messageList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mychatorderdetails);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
messageList = new ArrayList<HashMap<String, String>>();
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<String, String> row = new HashMap<String, String>();
row.put("type", "text");
row.put("details", "Order ID:"+order_id);
messageList.add(row);
HashMap<String, String> rowd = new HashMap<String, String>();
rowd.put("type", "text");
rowd.put("details", "Order Date:"+orderdate);
messageList.add(rowd);
HashMap<String, String> row1 = new HashMap<String, String>();
row1.put("type", "text");
row1.put("details",cust_name);
messageList.add(row1);
HashMap<String, String> row2 = new HashMap<String, String>();
row2.put("type", "text");
row2.put("details",cust_address);
messageList.add(row2);
HashMap<String, String> row3 = new HashMap<String, String>();
row3.put("type", "text");
row3.put("details","Pin:"+cust_pincode);
messageList.add(row3);
HashMap<String, String> row4 = new HashMap<String, String>();
row4.put("type", "text");
row4.put("details","Mob:"+cust_mobile);
messageList.add(row4);
HashMap<String, String> row5 = new HashMap<String, String>();
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<?> parent, View view, int position, long id) {
try {
HashMap<String, String> temp = new HashMap<String, String>();
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 < det.length(); i++) {
JSONObject cat = det.getJSONObject(i);
HashMap<String, String> row = new HashMap<String, String>();
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);
}
}
folgend ist der Code, zum meiner Liste ITEMS anzuzeigen. Ich wollte meine fünfte Zeile item d. H. UPI aktiviert kopieren, wenn lange gedrückt wird. Wie mache ich das? Bitte bearbeite meinen Code, damit das Gleiche passiert.In android: wie man Zeichenketten innerhalb von Listview macht, das Kopieren ermöglicht
.Ich verwende keine textview.Ich verwende eine ListView, um diese Liste anzuzeigen – tiji
Sie verwenden OrderDetailsAdapte Klasse, um die Liste anzuzeigen.Set Android: textIsSelectable = "True" in Adapter-Klasse – user2025187
Das wird meinen Text nur wählbar ist nicht it.I möchte den Text kopieren – tiji