1

I want to create like plugin for applications. When the specific button is clicked the webview should be opened on top of the app(activity). The whole logic for this webview should be in .jar library. It should not open new activity, because then I need to copy new layout(.xml file) in to project but I do not want to do this, because adding this new library (plugin) should be as simple as possible. I also should not change the existing layout.

Is any way to open this webview by just adding some lines of code to program and then control everything from library vithout making changes in layouts (.xml).

Update solution: I solve this by calling new activity from library but this activity does not load .xml layout but webView.

Project activity:

public void onClick(View v) {
startActivity(new Intent(MainActivity.this, LibraryActivity.class));
}

Library activity:

WebView web;
web= new WebView(this);
web.loadUrl("http://www.google.com");
web.setWebViewClient(new WebViewClient());      
setContentView(web);
ButterBeast
  • 521
  • 10
  • 25
  • 1
    For what purpose library is needed?? You can easily add `Views` on top of your layout. – Naddy Nov 29 '13 at 13:07
  • http://stackoverflow.com/questions/20274104/android-how-to-use-2-layout/20274177#20274177 – Naddy Nov 29 '13 at 13:08
  • I need to hide the content and then open the web page. I register on this web page and then when I register the web page closed. – ButterBeast Nov 29 '13 at 13:15

2 Answers2

1

Change your Activity's layout by setContentView(webView) and after the registration is done, again change the layout.

Edit:

After setting your layout by setContentView(R.layout.activity_main); invalidate your View :

ViewGroup vg =(ViewGroup) findViewById(R.id.Yourcontainer);
vg.invalidate();
Naddy
  • 2,664
  • 6
  • 25
  • 38
  • I try to do this and it works fine, but the problem is that when I return from webView all the click listener are gone. – ButterBeast Nov 29 '13 at 16:19
  • Thanks for your update. It works great, but I still prefer my solution because I do not have to know and R.id. But still thanks, you show me the way. – ButterBeast Nov 29 '13 at 22:51
0

The Android way of doing this is to raise an Intent with the URL that you wish to open as data passed through to the intent.

See the answer here for details of how to do that: Sending an Intent to browser to open specific URL

Community
  • 1
  • 1
Ben Pearson
  • 7,532
  • 4
  • 30
  • 50