FAQS


i want to use webview by clicking on an item in gridview

Views: 3250  |   Date: 2013-12-06 22:25:29

    	@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.image_grid);

GridView gridView = (GridView) findViewById(R.id.grid_view);

// Instance of ImageAdapter Class
gridView.setAdapter(new ImageAdapter(getApplicationContext()));

/**
* On Click event for Single GridView Item
* */
gridView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView parent, View v,
int position, long id) {

// for web view
WebView myWebView = (WebView) findViewById(R.id.webView2);
myWebView.loadUrl("http://www.facebook.com");

// Sending image id to FullScreenActivity
Intent i = new Intent(getApplicationContext(), WebTec.class);
// passing array index
i.putExtra("id", position);
startActivity(i);
}
});
}

 
Submit Your Answer
  |  
 
 
 

Preview :