Operation Sheet 3.1: Using List View in Building Mobile Application Menu
Operation Sheet 3.1: Using List View in Building Mobile Application Menu
Operation Sheet 3.1: Using List View in Building Mobile Application Menu
You can start your application development by calling start a new android studio
project. in a new installation frame should ask Application name, package
information and location of the project. Type the application name “GridView”
After entered application name, it going to be called select the form factors your
application runs on, here need to specify Minimum SDK, in our tutorial, I have
declared as API23: Android 6.0(Mashmallow) −
The next level of installation should contain selecting the activity to mobile, it
specifies the default layout for Applications.
At the final stage it going to be open development tool to write the application code.
If your AVD is created successfully it means your environment is ready for Android
application development.
Before Writing a Hello word code, you must know about XML tags.To write hello
word code, you should redirect to App>res>layout>Activity_main.xml. Drag the
GridView on the Activity.
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
B. Declare and Create an Array. Add the following code to main function.
ListView simpleList;
String countryList[] = {"India", "China", "australia", "Portugle",
"America", "NewZealand"};
int flags[] = {R.drawable.india, R.drawable.china, R.drawable.australia,
R.drawable.portugle, R.drawable.america, R.drawable.new_zealand};
import java.util.zip.Inflater;
@Override
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
view = inflter.inflate(R.layout.activity_listview, null);
TextView country = (TextView)
view.findViewById(R.id.textView);
ImageView icon = (ImageView) view.findViewById(R.id.icon);
country.setText(countryList[i]);
icon.setImageResource(flags[i]);
return view;
}