admin管理员组文章数量:1391969
I am trying to create a WebView in my MyGdxGame.java, In AIDE, The MyGdxGame.java is launched or configured from the MainActivity.java. Whether I build a single screen game, or multi screen game, I use the MyGdxGame.java exclusively. So, now I want to create a WebView, so I can display a Widget from the web; so it is html/text. Scenario: When I open the game app, I want the widget to be on the screen. Ideally, it would be linked from a Menu button created and positioned on the home page of this app, that when clicked, goes to another screen in the app and the widget is on that screen. . But for now, I would be content to have it shown on a single app screen, just to get it implemented. However, I am getting errors; I checked and re-added imports, so it is not an 'unknown entity' error per say; but the other error 'gdx-game-android, is missing, indicates, that perhaps gdx-game, has to communicate with gdx-game-android, I usually do not have to work with or include code at MainActivity.java,(its' default config code is pre loaded automatically for the template game app i use) but, because here I am attempting to code a WebView, while coding also with MyGdxGame.java; I think there is a crossover link that has to take place for gdx-game, and gdx-game-android, but I am not sure where to find or locate it. Coding in AIDE is unique compared to Android Studio, so perhaps someone with experiences in both, might have the answer.
Here is code from those sections, and the error code
ERRORS; at MainActivity.java constructor 'com.aac.game_webview.MyGdxGame.MyGdxGame(?) can not be applied to (com.aac.game_webview.MainActivity)
errors at MyGdxGame.java unknown entity 'MainActivity', maybe a reference to storage/emulated/0/AppProjects/WebView/gdx-game-android is missing
MyGdxGame.java
//here we code Main Activity with this
MainActivity mainActivity;
public MyGdxGame(MainActivity mainActivity) {
this.mainActivity = mainActivity;
}
@Override
public void create() {
MainActivity.java code
import com.aac.game_webview.MyGdxGame;
public class MainActivity extends AndroidApplication {
WebView webView;
WebSettings webSettings;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Context context = this;
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
MyGdxGame myGdxGame = new MyGdxGame(this);
initialize(myGdxGame, cfg);
webView = new WebView(this);
webView.setWebViewClient(new WebViewClient());
WebSettings webSettings = webView.getSettings();
//webView.getSettings().setJavaScriptEnabled(true);
webSettings.setJavaScriptEnabled(true);
//set cache for performance of app
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webSettings.setAppCacheEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
webView.loadDataWithBaseURL(null, "<script src= '.js'></script><div class ='coinlore- list-widget' data-mcurrency='eur' data-top= '10' data-cwidth='100%' data-bcolor='#fff' data- coincolor='#428bca' data-pricecolor='#4c4c4c'></div>", "text/html", "UTF-8", null);
setContentView(webView);
webView.setVisibility(View.VISIBLE);//to vis
}
@Override
public void onBackPressed()
{
if(webView.canGoBack()) {
webView.goBack();
} else {
super.onBackPressed();
}
}
public void showWebView() {
runOnUiThread(new Runnable() {
@Override
public void run() {
webView.setVisibility(View.VISIBLE);
}});}
public void hideWebView() {
(new Runnable()
@Override
public void run() {
webView.setVisibility(View.GONE);
}});
}}
本文标签:
版权声明:本文标题:android - In AIDE; How To Create a WebView While Working with MyGdxGame.java, and MainActivity.java - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744725097a2621915.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论