package com.android.qa;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class QuickAccessActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceSt ate);
setContentView(R.layout.main);
navigate();
}
public void navigate(){
Button google=(Button)findViewById(R. id.google);
Button facebook=(Button)findViewById( R.id.facebook);
Button youtube=(Button)findViewById(R .id.youtube);
Button twitter=(Button)findViewById(R .id.twitter);
Button myspace=(Button)findViewById(R .id.myspace);
Button linkedin=(Button)findViewById( R.id.linkedin);
Button flicker=(Button)findViewById(R .id.flicker);
google.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.google.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
facebook.setOnClickListener(ne w View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.facebook.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
youtube.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.youtube.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
twitter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.twitter.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
linkedin.setOnClickListener(ne w View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.linkedin.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
myspace.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.myspace.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
flicker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.myspace.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
}
}
//XML code(Layout)
----------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http:// schemas.android.com/apk/res/ android"
android:layout_width="fill_par ent"
android:layout_height="fill_pa rent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_par ent"
android:layout_height="wrap_co ntent"
android:text="@string/hello" />
<RelativeLayout
android:id="@+id/ relativeLayout1"
android:layout_width="match_pa rent"
android:layout_height="wrap_co ntent"
android:layout_weight="0.52" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_con tent"
android:layout_height="wrap_co ntent"
android:layout_alignParentLeft ="true"
android:layout_alignParentRigh t="true"
android:layout_alignParentTop= "true"
android:text="@string/google" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_con tent"
android:layout_height="wrap_co ntent"
android:layout_alignParentLeft ="true"
android:layout_alignParentRigh t="true"
android:layout_below="@+id/ button1"
android:layout_marginTop="18dp "
android:text="@string/ facebook" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_con tent"
android:layout_height="wrap_co ntent"
android:layout_alignParentLeft ="true"
android:layout_alignParentRigh t="true"
android:layout_below="@+id/ button2"
android:layout_marginTop="26dp "
android:text="@string/ twitter" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_con tent"
android:layout_height="wrap_co ntent"
android:layout_alignParentLeft ="true"
android:layout_alignParentRigh t="true"
android:layout_centerVertical= "true"
android:text="@string/orkut" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_con tent"
android:layout_height="wrap_co ntent"
android:layout_alignParentLeft ="true"
android:layout_alignParentRigh t="true"
android:layout_below="@+id/ button4"
android:layout_marginTop="24dp "
android:text="@string/ linkedin" />
<Button
android:id="@+id/button6"
android:layout_width="wrap_con tent"
android:layout_height="wrap_co ntent"
android:layout_alignParentLeft ="true"
android:layout_alignParentRigh t="true"
android:layout_below="@+id/ button5"
android:layout_marginTop="32dp "
android:text="Button" />
</RelativeLayout>
</LinearLayout>
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class QuickAccessActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceSt
setContentView(R.layout.main);
navigate();
}
public void navigate(){
Button google=(Button)findViewById(R.
Button facebook=(Button)findViewById(
Button youtube=(Button)findViewById(R
Button twitter=(Button)findViewById(R
Button myspace=(Button)findViewById(R
Button linkedin=(Button)findViewById(
Button flicker=(Button)findViewById(R
google.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.google.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
facebook.setOnClickListener(ne
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.facebook.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
youtube.setOnClickListener(new
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.youtube.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
twitter.setOnClickListener(new
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.twitter.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
linkedin.setOnClickListener(ne
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.linkedin.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
myspace.setOnClickListener(new
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.myspace.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
flicker.setOnClickListener(new
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String url="http://www.myspace.com";
Intent i=new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
}
}
//XML code(Layout)
----------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://
android:layout_width="fill_par
android:layout_height="fill_pa
android:orientation="vertical"
<TextView
android:layout_width="fill_par
android:layout_height="wrap_co
android:text="@string/hello" />
<RelativeLayout
android:id="@+id/
android:layout_width="match_pa
android:layout_height="wrap_co
android:layout_weight="0.52" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_con
android:layout_height="wrap_co
android:layout_alignParentLeft
android:layout_alignParentRigh
android:layout_alignParentTop=
android:text="@string/google" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_con
android:layout_height="wrap_co
android:layout_alignParentLeft
android:layout_alignParentRigh
android:layout_below="@+id/
android:layout_marginTop="18dp
android:text="@string/
<Button
android:id="@+id/button3"
android:layout_width="wrap_con
android:layout_height="wrap_co
android:layout_alignParentLeft
android:layout_alignParentRigh
android:layout_below="@+id/
android:layout_marginTop="26dp
android:text="@string/
<Button
android:id="@+id/button4"
android:layout_width="wrap_con
android:layout_height="wrap_co
android:layout_alignParentLeft
android:layout_alignParentRigh
android:layout_centerVertical=
android:text="@string/orkut" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_con
android:layout_height="wrap_co
android:layout_alignParentLeft
android:layout_alignParentRigh
android:layout_below="@+id/
android:layout_marginTop="24dp
android:text="@string/
<Button
android:id="@+id/button6"
android:layout_width="wrap_con
android:layout_height="wrap_co
android:layout_alignParentLeft
android:layout_alignParentRigh
android:layout_below="@+id/
android:layout_marginTop="32dp
android:text="Button" />
</RelativeLayout>
</LinearLayout>
No comments:
Post a Comment