1. Mainclass.java
2.main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:weightSum="1" android:background="#ffffff" android:orientation="vertical" android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:id="@+id/layoutTop"
android:background="#2B36DA"
>
<TextView
android:id="@+id/materailLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="RajuAndroidBlog"
android:textStyle="bold"
android:textSize="20dp"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:id="@+id/layoutScroll"
android:layout_below="@+id/layoutTop"
android:layout_marginBottom="5dp">
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/GridView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:numColumns="4"
android:columnWidth="60dp"
android:stretchMode="columnWidth"
android:gravity="center">
</GridView>
</RelativeLayout>
<RelativeLayout android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:layout_alignParentBottom="true">
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@+drawable/logo"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
</RelativeLayout>
package com.webtreak;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class MainClass extends Activity {
GridView grid_main;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
grid_main = (GridView)findViewById(R.id.GridView01);
grid_main.setAdapter(new ImageAdapter(this));
grid_main.setOnTouchListener(new OnTouchListener(){
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_MOVE){
return true;
}
return false;
}
});
grid_main.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
TextView tv=(TextView)v.findViewById(R.id.icon_text);
String selected_icon=tv.getText().toString();
//Intent intent=new Intent();
//String className="";
if(selected_icon.equalsIgnoreCase("The Wave")){
Intent intent=new Intent(MainClass.this,WaveActivity.class);
startActivityForResult(intent, 0);
}else if(selected_icon.equalsIgnoreCase("Schedules")){
Intent intent=new Intent(MainClass.this,SchedulesActivity.class);
startActivityForResult(intent, 0);
}
}
});
}
public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
//ImageView imageView;
View v;
if(convertView==null){
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.icon, null);
TextView tv = (TextView)v.findViewById(R.id.icon_text);
if(position==0){
tv.setText("The Wave");
}else if(position==1){
tv.setText("Schedules");
}else if(position==2){
tv.setText("Courses");
}else if(position==3){
tv.setText("Discussions");
}else if(position==4){
tv.setText("Talent Board");
}else if(position==5){
tv.setText("Resourses");
}else if(position==6){
tv.setText("Website");
}else{
tv.setText("TCC");
}
ImageView iv = (ImageView)v.findViewById(R.id.icon_image);
iv.setImageResource(mThumbIds[position]);
}
else
{
v = convertView;
}
return v;
}
// references to our images
private Integer[] mThumbIds = {
R.drawable.thewave, R.drawable.schedule,
R.drawable.courses, R.drawable.discussion,
R.drawable.talent, R.drawable.resourses,
R.drawable.website, R.drawable.tcc,
};
}
}
2.main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:weightSum="1" android:background="#ffffff" android:orientation="vertical" android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:id="@+id/layoutTop"
android:background="#2B36DA"
>
<TextView
android:id="@+id/materailLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="RajuAndroidBlog"
android:textStyle="bold"
android:textSize="20dp"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:id="@+id/layoutScroll"
android:layout_below="@+id/layoutTop"
android:layout_marginBottom="5dp">
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/GridView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:numColumns="4"
android:columnWidth="60dp"
android:stretchMode="columnWidth"
android:gravity="center">
</GridView>
</RelativeLayout>
<RelativeLayout android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:layout_alignParentBottom="true">
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@+drawable/logo"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
</RelativeLayout>
3.icon.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget44"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_x="201px"
android:layout_y="165px"
android:gravity="center_horizontal">
<ImageView
android:id="@+id/icon_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
<TextView
android:id="@+id/icon_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="10dp"
android:gravity="center_horizontal"
android:textColor="#000000">
</TextView>
</LinearLayout>
No comments:
Post a Comment