I'm trying to do the same thing.   I have a webview to display some
text formatted with html markup including bold, italics, and line
breaks.    But I need to know when a user clicks on this text.   I
suppose I could add javascript to get the click and then have the
javascript call back to the native app code; but that seems like too
much overkill.

On Nov 9, 7:28 am, Rajesh nyamgouda <[email protected]>
wrote:
> Trying to receive the onClick and onLongClick event on webview using
> below code but it failed to receive the event. Please help me out if
> anything is missing  or wrongly implemented to achieve the expected
> result.
>
> main.xml
> ==============================================================
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>     android:orientation="vertical"
>     android:layout_width="fill_parent"
>     android:layout_height="fill_parent"
>     >
>
>      <WebView
>         android:id="@+id/webview"
>         android:layout_width="100px"
>         android:layout_height="100px"
>     />
>
> </LinearLayout>
>
> ========================================================================
>
> HelloTest.java
>
> public class HelloTest extends Activity {
>
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>         WebView webview;
>
>         OnClickListener clickListen = new OnClickListener() {
>             public void onClick(View v) {
>                 System.out.println("########################## Inside
> CLICK LISTERNAER");
>             }
>         };
>
>         OnLongClickListener longclickListen = new
> OnLongClickListener() {
>             public boolean onLongClick(View v) {
>                 System.out.println("########################## Inside
> CLICK LISTERNAER");
>                 return true;
>             }
>         };
>
>         webview = (WebView) findViewById(R.id.webview);
>         webview.getSettings().setJavaScriptEnabled(true);
>         webview.setClickable(true);
>         webview.setLongClickable(true);
>         webview.setOnClickListener(clickListen);
>         webview.setOnLongClickListener(longclickListen);
>         webview.loadUrl("http://www.google.com";);
>    }
>
> }
>
> =========================================================================== =
>
> Manifest file
>
> <?xml version="1.0" encoding="utf-8"?>
> <manifest xmlns:android="http://schemas.android.com/apk/res/android";
>       package="com.agy.wrt.hellotest"
>       android:versionCode="1"
>       android:versionName="1.0">
>     <application android:icon="@drawable/icon" android:label="@string/
> app_name">
>         <activity android:name=".HelloTest"
>                   android:label="@string/app_name">
>             <intent-filter>
>                 <action android:name="android.intent.action.MAIN" />
>                 <category
> android:name="android.intent.category.LAUNCHER" />
>             </intent-filter>
>         </activity>
>
>     </application>
>     <uses-sdk android:minSdkVersion="8" />
>         <uses-permission android:name="android.permission.INTERNET" />
>
> </manifest>
> =======================================================================

-- 
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

Reply via email to