Android code to make list and load static html using Intent. Complete sample code discussed.

This is an experiment application in android to create a list of buttons with attached html content. Once the user clicks the buttons static html web pages are loaded on the device screen. A simple app to start learning android development and intents.

This project has manual changes to three source code files of Android 4.2 project.

activity_main.xml - This file is updated to LinearLayout with two Android buttons to call html.

strings.xml - This file is updated to provide string values to the button text.

MainActivity.java - This file has a new method to startActivity with click from android buttons.

We will discuss details on each code change next.

activity_main.xml code below.

This file is located under project_name/res/layout/activity_main.xml

activity_main.xml

LTE - 4G Wireless Technology

Digital fundamentals.

Interview Questions.

In activity_main.xml code we have used LinearLayout for the display.

Inside LinearLayout we have defined two Buttons with android:text as “@string”.

So the two buttons will need to be defined in strings.xml file.

android:text="@string/intro"

android:text="@string/initial"

The way android is going to interpret these buttons are “string values”. We will cover the strings.xml next.

~\Documents\fullchip\python\mysite\webpages\templates\webpages\test.py.html
<?xml version="1.0" encoding="utf-8"?>
<resources>
   <string name="app_name">fcd</string>
   <string name="menu_settings">Settings</string>
   <string name="intro">Verilog Introduction</string>
   <string name="initial">Initial Block</string>
</resources>

Tutorials @fullchipdesign.com

Verilog Tutorial.

LTE Tutorial.

Memory Tutorial.

In the above code we see two strings. To match our andoid:text from activity_main.xml.

These are added into XML format directly. The other way is to enter the new strings through GUI.

Next we will discuss code MainActivity.java

This is an experiment application in android to create a list of buttons with attached html content. Once the user clicks the buttons static html web pages are loaded on the device screen. A simple app to start learning android development and intents.

This project has manual changes to three source code files of Android 4.2 project.

activity_main.xml - This file is updated to LinearLayout with two Android buttons to call html.

strings.xml - This file is updated to provide string values to the button text.

MainActivity.java - This file has a new method to startActivity with click from android buttons.

package com.example.fcd;

import android.net.Uri;

import android.os.Bundle;

import android.app.Activity;

import android.content.Intent;

import android.view.Menu;

import android.view.View;

public class MainActivity extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

 super.onCreate(savedInstanceState);

 setContentView(R.layout.activity_main);

}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

 // Inflate the menu; this adds items to the action bar if it is present.

 getMenuInflater().inflate(R.menu.activity_main, menu);

 return true;

}

 public void load (View view) {

 String url = "verilog.htm";

 Intent intent= new Intent(Intent.ACTION_VIEW);

 intent.setData(Uri.parse(url));

 // incorrect - intent.setData(Uri.parse("content://intro.txt"));

 startActivity(intent);

 // do something

}

 public void load2 (View view) {

 String url = "verilog_initial_clocks_reset.htm";

 Intent intent= new Intent(Intent.ACTION_VIEW);

 intent.setData(Uri.parse(url));

 // incorrect - intent.setData(Uri.parse("content://intro.txt"));

 startActivity(intent);

 // do something

}

}

Above two lines of code are required to invoke methods to load intents. These intents will inturn parse html web-pages. Lets review the complete code below. MainActivity.java code is located under project_name/src/com/example/project_name/MainActivity.java

Hope you liked! this page. Don't forgot to access relevant previous and next sections with links below.