How can I click on a button (phone number) and it copies it and show me that it was copied?
activity_main.xml
<Button
android:id="@+id/phonenumberhotel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Tel.: 00000 0 000 0000"/>
MainActivity.java
package com.iss.dfdfd;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.text.ClipboardManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;
public class PageOneHotel extends Activity {
Button phonenumberhotel;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hotel);
Toast.makeText(getBaseContext(), "Phone number has been copied", Toast.LENGTH_LONG).show();
addButtonListener();
addListenerOnButton();
}
public void addListenerOnButton() {
phonenumberhotel = (Button) findViewById(R.id.phonenumberhotel);
phonenumberhotel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO add action here
}
});
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("label", "Copied");
}
}
I did that, the number is not copied, only a msg appears from the toast .. I just want to click on the button and it tells me the number is copied. When I go to the dialer, it pastes nothing .. help :)