Legal Disclaimer

Tech in your hand
An easy approach to understand tech specs
Learn to Impress
  FullChipDesign
Home.
Home.Pics.LTE Home.OFDMA  .

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:tools="http://schemas.android.com/tools"

   android:layout_width="wrap_content"

   android:layout_height="match_parent"

   android:gravity="top"

   tools:context=".MainActivity" >

       

    <Button

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:text="@string/intro"

           android:onClick="load" />

   

    <Button

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:text="@string/initial"

           android:onClick="load2" />

       

</LinearLayout>

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

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.   

 

<?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>

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 = "http://www.fullchipdesign.com/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 = "http://www.fullchipdesign.com/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

Advance GVIM commands using RegEX:

How to remove empty/blank lines from text file using regular expressions ?

 

How to merge multiple blank lines into one blank line without touching the single blank line separating text?

 

How to drop blank characters at end of the line? Do it for only a range of lines text file?

 

How to search numbers in text file?

 

The number can have any number of digits with each digit in range 0 to 9.

 

How to do search and replace exact word in text file excluding includes.

 

How to duplicate columns in GVIM? Repeat the same text twice on every line.

Move up and down from current line by  a fixed number?

 

Revert changes in gvim based on time? Go to older changes in time.  

 

How to run shell commands from gvim in unix?

 

How to compile your code from within the program? How to use make in GVIM?

 

How to create markers in gvim editor? Easy to navigate while editing a file.

 

How to enable spell check  & command to import language specific dictionary?

 

How to set syntax in gvim for filetypes like perl, python, verilog?

 

How to reverse the order of lines in entire file and also show the command for just a block of text?

 

How to move to home, middle or Last line of current view?

 

How to show/remove line numbers?

 

How to Remove highlights or color from text file? Simply do :nohls

 

How to Search in a text file ?

Simply do /<search_pattern>

Anything after / will be search pattern to find in file.

 

How to set Ignore case in text file for search? :set ic

How to open multiple files in GVIM?

Use :split <path_of_file>

How to switch between multiple files using only keyboard in GVIM editor?

When multiple files are open in gvim editor, use ctrl+w 2 times to jump in-between files.

How to merge the line with line below? Shift+j or capital J

 

How to change text to lowercase or uppercase?

gu{motion} - As you move the up/down arrows the lines will change to all lower case.

gU{motion} - As you move the up/down arrows the line will change to all upper case.