Passing Data of WebView to Another Activity
- by meygraph
I've designed a training program and Html texts and image put into training.
I want to address my html file by an activity to sent another activity.
This is MainActivity
/*
* ListView item click listener. So we'll have the do stuff on click of
* our ListItem
*/
listViewArticles.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
switch (position) {
case 0:
Intent newActivity0 = new Intent(TrickPage.this,a_Dotted_Lines.class);
startActivity(newActivity0);
break;
case 1:
Intent newActivity1 = new Intent(TrickPage.this,TutorialsPage.class);
startActivity(newActivity1);
break;
case 2:
Intent newActivity2 = new Intent(TrickPage.this,TutorialsPage.class);
startActivity(newActivity2);
break;
case 3:
Intent newActivity3 = new Intent(TrickPage.this,TutorialsPage.class);
startActivity(newActivity3);
break;
default:
// Nothing do!
}
and this SecondActivity (show WebView)
public class a_Dotted_Lines extends Activity {
private WebView webView;
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.a_dotted_lines);
// Button HOME
ImageButton ImageButton_home = (ImageButton) findViewById(R.id.ImageButton_home);
ImageButton_home.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(a_Dotted_Lines.this, Main.class);
startActivity(intent);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
}
});
//Button Previous
ImageButton ImageButton_previus = (ImageButton)
findViewById(R.id.ImageButton_previus);
ImageButton_previus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Closing SecondScreen Activity
finish();
}
});
webView = (WebView) findViewById(R.id.webview_compontent);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/html/article.htm");
}
}
I want Send "file:///android_asset/html/article.htm" or other addres from MainActivity
Is it possible?
Sorry My English is not good