Hello Aki,
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.text.ClipboardManager;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.Toast;
public class TryDemoActivity extends Activity implements
OnClickListener {
private WebView webview1;
private Button copyButton;
private Button pasteButton;
private Button highlightButton;
private ClipboardManager clipboard;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview1 = (WebView) findViewById(R.id.webview);
copyButton = (Button) findViewById(R.id.copy);
pasteButton = (Button) findViewById(R.id.paste);
webview1.loadUrl("file:///android_asset/1.1.html");
clipboard =
(ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
copyButton.setOnClickListener(this);
pasteButton.setOnClickListener(this);
}
private void emulateShiftHeld(WebView view)
{
try
{
KeyEvent shiftPressEvent = new KeyEvent(0, 0,
KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
shiftPressEvent.dispatch(view);
registerForContextMenu(view);
Toast.makeText(this, "select_text_now",
Toast.LENGTH_SHORT).show();
}
catch (Exception e)
{
Log.e("dd", "Exception in emulateShiftHeld()", e);
}
}
@Override
public void onClick(View v) {
switch(v.getId())
{
case R.id.copy:
emulateShiftHeld(webview1);
break;
case R.id.paste:
Toast.makeText(this, clipboard.getText(),
Toast.LENGTH_SHORT).show();
break;
}
}
}
It's working fine till android 2.3.But i have to same work on android
3.0
On Nov 24, 11:09 am, Aki <[email protected]> wrote:
> Hi Shweta,
>
> Can you post the code you have written?
>
> Regards,
> Aki
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en