title: navigation drawer not opening for webview button click
body: <p>I am trying to open a nav drawer when user clicks on a webview (HTML) button. I have a code which works fine when I use Android button but it does not work when I use HTML button. The navigation drawer shows when you drag it from left side but not when you click the HTML button.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>activity_main
  
  &lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@android:color/background_light"
          android:orientation="vertical" &gt;
  
         &lt;!-- &lt;Button
              android:id="@+id/button1"
              android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:onClick="open"
              android:text="Button" /&gt;  --&gt;
              
              
              &lt;WebView
           android:id="@+id/webView1"
           android:layout_width="match_parent"
           android:layout_height="match_parent" /&gt;
        
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/drawer"
          android:layout_width="240dp"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:background="@android:color/background_light"
          android:orientation="vertical"
          android:padding="5dp" &gt;
  
          &lt;fragment
              android:id="@+id/fragment1"
              android:name="com.example.webviewnav.MyListFragment1"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_weight="1" /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>MyListFragment1
  
  public class MyListFragment1 extends ListFragment {
  
   String[] month = { "January", "February", "March", "April", "May", "June",
     "July", "August", "September", "October", "November", "December" };
  
   @Override
   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListAdapter myListAdapter = new ArrayAdapter&lt;String&gt;(getActivity(),
      android.R.layout.simple_list_item_1, month);
    setListAdapter(myListAdapter);
   }
  
   @Override
   public View onCreateView(LayoutInflater inflater, ViewGroup container,
     Bundle savedInstanceState) {
    return inflater.inflate(R.layout.listfragment1, container, false);
   }
  
   @Override
   public void onListItemClick(ListView l, View v, int position, long id) {
    // TODO Auto-generated method stub
    Toast.makeText(getActivity(),
      getListView().getItemAtPosition(position).toString(),
      Toast.LENGTH_LONG).show();
   }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>MainActivity
  
  public class MainActivity extends Activity {
   
   private DrawerLayout drawerLayout;
   private View drawerView;
   WebView wv;
  
   @SuppressLint("SetJavaScriptEnabled")
   @Override
   protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    drawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
    drawerView = (View)findViewById(R.id.drawer);
    
    /*Button buttonOpenDrawer = (Button)findViewById(R.id.opendrawer);
    buttonOpenDrawer.setOnClickListener(new OnClickListener(){
  
     @Override
     public void onClick(View arg0) {
      drawerLayout.openDrawer(drawerView);
     }
    }); */
    
     wv = (WebView)findViewById(R.id.webView1);
      wv.getSettings().setJavaScriptEnabled(true);
      wv.addJavascriptInterface(new WebAppInterface(this), "Luke");
      wv.loadUrl("file:///android_asset/www/mind.html"); 
    
    drawerLayout.setDrawerListener(myDrawerListener);
   } //onCreate ends
  
   DrawerListener myDrawerListener = new DrawerListener(){
  
    @Override
    public void onDrawerClosed(View drawerView) {
     //textPrompt.setText("onDrawerClosed");
    }
  
    @Override
    public void onDrawerOpened(View drawerView) {
     //textPrompt.setText("onDrawerOpened");
    }
  
    @Override
    public void onDrawerSlide(View drawerView, float slideOffset) {
     //textPrompt.setText("onDrawerSlide: " + String.format("%.2f", slideOffset));
    }
  
    @Override
    public void onDrawerStateChanged(int newState) {
     String state;
     switch(newState){
     case DrawerLayout.STATE_IDLE:
      state = "STATE_IDLE";
      break;
     case DrawerLayout.STATE_DRAGGING:
      state = "STATE_DRAGGING";
      break;
     case DrawerLayout.STATE_SETTLING:
      state = "STATE_SETTLING";
      break;
     default:
      state = "unknown!";
     }
      
     //textPrompt2.setText(state);
    }};  
   
    
    public class WebAppInterface {
        Context mContext;
  
        
        WebAppInterface(Context c) {
            mContext = c;
        }
  
        
        @JavascriptInterface
        public void showDialog() {
            
         
         drawerLayout.openDrawer(drawerView);
         
         //Toast.makeText(getApplicationContext(), "Good", Toast.LENGTH_SHORT).show();
        }
    } 
    
    /*public void open(View v){
     drawerLayout.openDrawer(drawerView);
    } */
   
   
   
   
   
   
  } //Activity ends</code></pre>
  </div>
  </div>
  </p>