Guns'n'Glory Heroes

Posted by Unknown Kamis, 24 Januari 2013 0 komentar

Sharpen the axe, polish your armor and ready your guns! It's time to fight for glory, honor and gold once more! Guns'n'Glory is back!
Features:
✔Newest entry in the popular Guns’n’Glory series
✔Epic fantasy defense action with Elves and Dwarves
✔Control 3 mighty heroes in their battle against the Orcs
✔Use and improve your 12 powerful combat abilities
✔Journey into forests, swamps and snowy mountains in 50 challenging levels
✔Experience an enchanting storyline spanning 5 exciting chapters
✔Prove your tactical skills and master the Heroic Difficulty mode
The realm is under attack as Orcs, apostate Elves and dark knights roam the lands! Help our heroes Smirl, Arlon and Eloa in their epic struggle against this evil menace! Harness the power of light and face your enemies! Annihilate whole armies with magical fire and ice! Unleash the Dwarven Fury upon your foes and split Orcs skulls! Join your party of stalwart heroes and become the Champion of the Hill Lands!
* Supports Immersion haptic technology *
From the developer of:
Guns and Glory, Guns & Glory WW2, Guns & Glory Heroes, Clouds & Sheep, Super Dynamite Fishing, Townsmen, Epic Battle Dude, Aporkalypse - Pigs of Doom, Farm Invasion USA, Save the Puppies, Rocket Island, Tattoo Tycoon, Happy Vikings, Panzer Panic, Shark or Die, Casino Crime, Bulldozer, Cyberlords - Arcology, Candy Carnage, Tattoo Mania & Infecct.
please support us by clicking on +1 button .
contact for more games and apps - saxenak96@gmail.com
Thanks - KARAN

Baca Selengkapnya ....

Spinners in Android

Posted by Unknown 0 komentar
The Android Spinner Control is definitely the equivalent of the drop-down selector . By making use of spinner control you basically obtain the capability to choose from a list without taking up all of the display screen space of a ListView.

Spinners provide a quick way to select one value from a set. In the default state, a spinner shows its currently selected value. Touching the spinner displays a dropdown menu with all other available values, from which the user can select a new one.

You can add a spinner to your layout with the Spinner object. You should usually do so in your xml layout with a  <spinner>  element.
For example:
 <Spinner
   
        android:id="@+id/myspinner"   
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

Here we go with java source code:
in java file:
 
public class simplespinnersactivity extends Activity implements OnItemSelectedListener {
TextView selection;
String[] items = { "this", "is", "a","really","a" "simple","list", "in", "android", "ok" };

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
selection = (TextView) findViewById(R.id.selection);
Spinner spin = (Spinner) findViewById(R.id.spinner);
spin.setOnItemSelectedListener(this);
ArrayAdapter aa = new ArrayAdapter(this,android.R.layout.simple_spinner_item,items);
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(aa);
}
public void onItemSelected(AdapterView parent, View v,int position,long id)
{
selection.setText(items[position]);
}
public void onNothingSelected(AdapterView parent)
{
selection.setText("");
}
}

in xml file:
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/selection"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"/>

<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop = "true">

</Spinner>
</LinearLayout>

Baca Selengkapnya ....

Show and Resume Android Soft-Keyboard

Posted by Unknown Rabu, 23 Januari 2013 0 komentar
Code to show keyboard:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(yourEditText,InputMethodManager.SHOW_IMPLICIT);
Code resume keyboard :

InputMethodManager imm = (InputMethodManager)gettSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0);

Baca Selengkapnya ....

Blinking TextView - Two Methods

Posted by Unknown 0 komentar
METHOD 1

private void blink(){
final Handler handler = new Handler();
new Thread(new Runnable() {
public void run() {
int timeToBlink = 600; //in milissegunds
try
{
Thread.sleep(timeToBlink);
}catch (Exception e)
{

}handler.post(new Runnable()
{
public void run()
{
TextView txt = (TextView)findViewById(R.id.usage);
if(txt.getVisibility() == View.VISIBLE)
{
txt.setVisibility(View.INVISIBLE);
}else
{
txt.setVisibility(View.VISIBLE);
}
blink();
}
});
}
}).start();
}
METHOD 2

TextView myText = (TextView) findViewById(R.id.usage );
Animation anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(50);
//You can manage the time of the blink with this parameter
anim.setStartOffset(20);
anim.setRepeatMode(Animation.REVERSE);
anim.setRepeatCount(Animation.INFINITE);
myText.startAnimation(anim);

Baca Selengkapnya ....

Creating an Activity as a Dialog Box

Posted by Unknown 0 komentar
In Android ManifestFile :


<activity android:name=".DialogActivity" android:theme="@android:style/Theme.Dialog"> </activity>

Baca Selengkapnya ....

Calling a Service from Activity in Android

Posted by Unknown 0 komentar
This is a service class:

public class serv extends Service {
private static final String TAG = "MyService";
AlertDialog alertDialog
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
public void onCreate() {
Toast.makeText(getApplicationContext(), "My Service Created",Toast.LENGTH_LONG).show();
}
@Override
public void onDestroy() {
Toast.makeText(this, "My Service Stopped",Toast.LENGTH_LONG).show();
Log.d(TAG, "onDestroy");
//player.stop();
}
@Override
public void onStart(Intent intent, int startid) {
Toast.makeText(this, "My Service Started",Toast.LENGTH_LONG).show();
Log.d(TAG, "onStart");
//player.start();
}
}
Call service from activity:

public class MainActivity extends Activity {
private static final String TAG = "ServicesDemo";
Button buttonStart, buttonStop;
PendingIntent pendingIntent;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent i;
i=new Intent(MainActivity.this,serv.class);
startService(i);
}}

Baca Selengkapnya ....

Customize The Title Bar in Android

Posted by Unknown 0 komentar
xml for custom title bar:

< ?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/titlebar>
< TextView
style="@style/MyRedTextAppearance"
android:padding="7dp"
android:id="@+id/txtvew_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#FFFFFF"
android:textSize="20dp"
android:textStyle="bold"
android:gravity="center"/>
< /LinearLayout>
main.xml:
Include the above xml to the main xml as given below...

< RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/redbg" >
< include
android:id="@+id/head"
layout="@layout/titlebaar" />
< LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/head"
android:padding="5dp" >
--- ---- --- ---- --- --- -- --
--- --- ---- --- --- --- --- --
< /LinearLayout>
< /RelativeLayout>
in java class:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.show_image);

TextView t1 = (TextView) findViewById(R.id.txtvew_title);
t1.setText("Custom Title Bar");
t1.setTextColor(Color.RED);
}

Baca Selengkapnya ....

How to use RadioButtonGroup in Android?

Posted by Unknown 0 komentar
in xml page:

< ?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
< TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Which company do you like the most?"
android:textSize="25dp"
android:textStyle="bold" />
< RadioGroup
android:id="@+id/menu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:checkedButton="@+id/lunch"
android:orientation="vertical" >
< RadioButton
android:id="@+id/google"
android:checked="true"
android:text="Google" />
< RadioButton
android:id="@+id/ms"
android:text="Microsoft" />
< RadioButton
android:id="@+id/apple"
android:text="Apple" />
< RadioButton
android:id="@+id/nokia"
android:text="Nokia" />
< RadioButton
android:id="@+id/samsung"
android:text="Samsung" />
< /RadioGroup>
< TextView
android:id="@+id/choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text=""
android:textSize="25dp" />
< Button
android:id="@+id/clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clear CheckBoxes" />
< /LinearLayout>
in Java Class:

public class Page Flipping extends Activity implements
RadioGroup.OnCheckedChangeListener, View.OnClickListener {

private TextView mChoice;
private RadioGroup mRadioGroup;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_page_flipping);
mRadioGroup = (RadioGroup) findViewById(R.id.menu);
// test listening to checked change events
mRadioGroup.setOnCheckedChangeListener(this);
mChoice = (TextView) findViewById(R.id.choice);
// test clearing the selection
Button clearButton = (Button) findViewById(R.id.clear);
clearButton.setOnClickListener(this);
}

public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.google) {
mChoice.setText("Selected Google");
}
if (checkedId == R.id.ms) {
mChoice.setText("Selected Microsoft");
}
if (checkedId == R.id.apple) {
mChoice.setText("Selected Apple");
}
if (checkedId == R.id.nokia) {
mChoice.setText("Selected Nokia");
}
if (checkedId == R.id.samsung) {
mChoice.setText("Selected Samsung");
}
}

public void onClick(View v) {
mRadioGroup.clearCheck();
}
}

Baca Selengkapnya ....

Option Menu in Android

Posted by Unknown Kamis, 17 Januari 2013 0 komentar
menu.xml :

< ?xml version="1.0" encoding="utf-8"?>
< menu xmlns:android="http://schemas.android.com/apk/res/android">
< item android:id="@+id/item1" android:title="Option 1"
android:icon="@android:drawable/ic_menu_compass"/>
< item android:id="@+id/item2" android:title="Option 2"
android:icon="@android:drawable/ic_menu_week"/>
< item android:id="@+id/item3" android:title="Option 3"
android:icon="@android:drawable/ic_menu_call"/>
< item android:id="@+id/item4" android:title="Option 4"
android:icon="@android:drawable/ic_menu_zoom"/>
< /menu>
Click on the menu button to open this menu
in java class :

public class OptionMenuActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater inflater=getMenuInflater();
inflater.inflate(R.layout.menu,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
if(item.getItemId()==R.id.item1)
{
Log.d("option","Option 1 was clicked");
}
if(item.getItemId()==R.id.item2)
{
System.out.println("item2 selected");
}
if(item.getItemId()==R.id.item3)
{
System.out.println("item3 selected");
}
if(item.getItemId()==R.id.item4)
{
System.out.println("item4 selected");
}
return super.onOptionsItemSelected(item);
}
}

Baca Selengkapnya ....

ContextMenu in Android

Posted by Unknown 0 komentar
Long click on the button to open the menu.
in java class:

public class ContextmenuActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button b=(Button)findViewById(R.id.button1);
registerForContextMenu(b);
}
//create the menuuu======================
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater=getMenuInflater();
inflater.inflate(R.layout.contextmenu, menu);

}
//click to each menu======================
@Override
public boolean onContextItemSelected(MenuItem item) {
// TODO Auto-generated method stub
if(item.getItemId()==R.id.item1)
{
System.out.println("item1 clicked");
}
if(item.getItemId()==R.id.item2)
{
System.out.println("item2 clicked");
}
if(item.getItemId()==R.id.item3)
{
System.out.println("item3 clicked");
}
if(item.getItemId()==R.id.item4)
{
System.out.println("item4 clicked");
}
return super.onContextItemSelected(item);
}}

Context Menu Xml:

< ?xml version="1.0" encoding="utf-8"?>
< menu xmlns:android="http://schemas.android.com/apk/res/android">
< group android:checkableBehavior="single">
< item android:id="@+id/item1" android:title="Item 1" />
< item android:id="@+id/item2" android:title="Item 2" />
< item android:id="@+id/item3" android:title="Item 3" />
< item android:id="@+id/item4" android:title="Item 4" />
< /group>
< /menu>
in 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:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center">
< Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
< /RelativeLayout>
         

Baca Selengkapnya ....

Custom AlertBox in Android

Posted by Unknown Rabu, 16 Januari 2013 0 komentar
in main.xml file:

< ?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

< Button
android:id="@+id/button1"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="Button" />

< /LinearLayout>
in dialog.xml :(xml for custom dialog box) :

< ?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

< ImageView
android:id="@+id/imageView1"
android:layout_width="210dp"
android:layout_height="232dp"
android:padding="40dp"
android:src="@drawable/flower" />

< TextView
android:id="@+id/textView1"
android:layout_width="147dp"
android:layout_height="wrap_content"
android:text="This is a flower"
android:textSize="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"/>

< /LinearLayout>
in java file:

Button b= (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Dialog d=new Dialog(CustomdialogActivity.this);
d.setContentView(R.layout.dialog);
d.setTitle("This is important");
d.show();
}
});


Baca Selengkapnya ....

Vertical Text in Xml in Android

Posted by Unknown Selasa, 15 Januari 2013 0 komentar
A simple way is to insert a \n after each character, and make sure that the the height is set to fill_parent.

< TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="h\ne\nl\nl\no\n w\no\nr\nl\nd" />

Baca Selengkapnya ....

Frame by Frame Animation in Android

Posted by Unknown 0 komentar
Call a new xml file which includes the frames that are to be loaded:

< ?xml version="1.0" encoding="utf-8"?>
< animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android">
< item android:drawable="@drawable/frame_above95_1" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_2" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_3" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_4" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_5" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_6" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_7" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_8" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_9" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_10" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_11" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_12" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_13" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_14" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_15" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_16" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_17" android:duration="30"/>
< item android:drawable="@drawable/frame_above95_18" android:duration="30"/>
< /animation-list>
in java file:

img1.setBackgroundResource(R.layout.animation_above95);
AnimationDrawable anim=(AnimationDrawable)img1.getBackground();
anim.start();

Baca Selengkapnya ....

Download an Image from Url and Display it in a ImageView

Posted by Unknown 0 komentar

Bitmap bmImg;
ImageView img1;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.sending_card);
img1=(ImageView) findViewById(R.id.imageView1);
String url="http://i.123g.us/c/efeb_valen_happy/card/107397.gif";
downloadFile(url);
}
void downloadFile(String fileUrl){
URL myFileUrl =null;
try {
myFileUrl= new URL(fileUrl);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
HttpURLConnection conn=
(HttpURLConnection)myFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bmImg = BitmapFactory.decodeStream(is);
img1.setImageBitmap(bmImg);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}

Baca Selengkapnya ....

Read from Asset and Write to a TextView

Posted by Unknown Jumat, 11 Januari 2013 0 komentar
Code for reading from a text file in asset folder to a textview:


public class Readfile extends Activity {
String path;
ArrayList data = new ArrayList();

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
path = getResources().getString(R.string.directory1);
String[] data1 = null;
AssetManager am = getResources().getAssets();
try {
data1 = am.list(path);
} catch (Exception e) {
}
for (String name : data1) {
data.add(name);
}
Readoperation();
}
public void Readoperation() {
// TODO Auto-generated method stub
TextView txt = (TextView) findViewById(R.id.text);
try {
path=getResources().getString(R.string.directory1) +"/"+data.get(2);
InputStream stream = getAssets().open(path);
int size = stream.available();
byte[] buffer = new byte[size];
stream.read(buffer);
stream.close();
txt.setText(Html.fromHtml(new String(buffer).trim()));
}
catch (IOException e) {
}}

Baca Selengkapnya ....

Swipe Image Viewer in Android

Posted by Unknown 0 komentar

See more basics on Android along with interview questions


public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ViewPager viewPager = (ViewPager)findViewById(R.id.view_pager);
ImagePagerAdapter adapter = new ImagePagerAdapter();
viewPager.setAdapter(adapter);
}
private class ImagePagerAdapter extends PagerAdapter {
private int[] mImages = new int[] {
R.drawable.chiang_mai,
R.drawable.himeji,
R.drawable.petronas_twin_tower,
R.drawable.ulm
};
@Override
public int getCount() {
return mImages.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((ImageView) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
Context context = MainActivity.this;
ImageView imageView = new ImageView(context);
int padding = context.getResources().getDimensionPixelSize(
R.dimen.padding_medium);
imageView.setPadding(padding, padding, padding, padding);
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
imageView.setImageResource(mImages[position]);
((ViewPager) container).addView(imageView, 0);
return imageView;
}
@Override
public void destroyItem(ViewGroup container, int position,Object object) {
((ViewPager) container).removeView((ImageView) object);
}
}
}

Baca Selengkapnya ....

Implementing Share Intent in Android

Posted by Unknown 0 komentar
Create a sharing button and inside the listen for button click call the share intent



Intent sharingIntent = newIntent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "Insert the share content body"; sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Insert Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
Note: Give internet permission in android manifest file

< uses-permission android:name="android.permission.INTERNET"/>

Baca Selengkapnya ....

Showing Selected Grid Image in New Activity (Full Screen)

Posted by Unknown Selasa, 08 Januari 2013 0 komentar
in main java class:

gridView = (GridView) findViewById(R.id.gridView1);
gridView.setAdapter(new ImageAdapter(this));
gridView.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView parent,View v,int position,long id)
{
System.out.println("====>>"+position);
Intent i = new Intent(getApplicationContext(),GidImage.class);
// passing array index
i.putExtra("id", position);
startActivity(i);
}
});
create a new java file with an image view:

Intent i = getIntent();
// Selected image id
int position = i.getExtras().getInt("id");
ImageAdapter imageAdapter = new ImageAdapter(this);
ImageView imageView =(ImageView)
findViewById(R.id.full_image_view);

imageView.setImageResource(imageAdapter.mThumbIds[position]);
in custom Adapter class:

public class ImageAdapter extends BaseAdapter {
private Context context;
public Integer[] mThumbIds = {
R.drawable.card0, R.drawable.card1,
R.drawable.card2, R.drawable.card3,
R.drawable.card0, R.drawable.card1,
R.drawable.card2, R.drawable.card3,
R.drawable.card0, R.drawable.card1,
R.drawable.card2, R.drawable.card3
};
public ImageAdapter(Context context) {
this.context = context;
}
@Override
public int getCount() {
return mThumbIds.length;
}

@Override
public Object getItem(int position) {
return mThumbIds[position];
}

@Override
public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView = new ImageView(context);
imageView.setImageResource(mThumbIds[position]);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(new GridView.LayoutParams(130, 100));
imageView.setPadding(8, 8, 8, 8);
return imageView;
}
}

Baca Selengkapnya ....

Copying an Array and Sorting it in Corona

Posted by Unknown 0 komentar

copyarray = table.copy( randomArray)
local function compare( a, b )
return a < b
end
table.sort( copyarray, compare )

Baca Selengkapnya ....

Function to Generate a Set of Random Numbers in Corona

Posted by Unknown 0 komentar

Call this function to generate a set of five random numbers (maxRandom)...


local function generaterandom()
local maxRandom = 5
for m = 1, randCount do
randomArray[m]=-100
end
local i = 1
while i
local randNum = math.random (1, maxRandom)
local flagNew = false
for j = 1 , randCount do
if randomArray[j]==randNum then
flagNew = true
break
end
end
if flagNew==false then
randomArray[i]=randNum
i=i+1
end
end
for k=1, randCount do
print("Values---->".. randomArray[k])
end
end

Baca Selengkapnya ....

Disabling the Touch of an Activity

Posted by Unknown Senin, 07 Januari 2013 0 komentar

On a button click we are creating the same class as a dialog so that the touch is not received


public class MainActivity extends Activity {
Dialog overlayDialog;
EditText edt;
Button bt;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

edt=(EditText)findViewById(R.id.editText1);
bt=(Button)findViewById(R.id.button1);
bt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
disableAnyInput();
}
});
}
public void disableAnyInput(){
Toast.makeText(getApplicationContext(), "This will disable any input. Click the backbutton "
+ "to enable any input.", Toast.LENGTH_LONG).show();
overlayDialog = new Dialog(MainActivity.this,android.R.style.Theme_Panel);
overlayDialog.setCancelable(true);
overlayDialog.show();
} }

Baca Selengkapnya ....

Marquee Text in Android

Posted by Unknown 0 komentar
in xml file:

< TextView
android:id="@+id/MarqueeText"
android:layout_width="wrap_content"
android:marqueeRepeatLimit="marquee_forever"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:scrollHorizontally="true"
android:singleLine="true"
android:layout_marginTop="300dp"
android:text="This is a very long text which is not fitting in the screen so it needs to be marqueed." />

Baca Selengkapnya ....

Passing Images between Activities in Android

Posted by Unknown 0 komentar
in First Activity:

Intent intent=new Intent(FirstClass.this, SecondClass.class);
Bundle bundle=new Bundle();
bundle.putInt("image",R.drawable.ic_launcher);
intent.putExtras(bundle);
startActivity(intent);
in Second Acticity:

Bundle bundle=this.getIntent().getExtras();
int pic=bundle.getInt("image");
v.setImageResource(pic);
another method:
in First Activity:

Drawable drawable=imgv.getDrawable();
Bitmap bitmap= ((BitmapDrawable)drawable).getBitmap();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] b = baos.toByteArray();
Intent intent=new Intent(Passimage.this,myclass.class);
intent.putExtra("picture", b);
startActivity(intent);
in Second Acticity:

Bundle extras = getIntent().getExtras();
byte[] b = extras.getByteArray("picture");
Bitmap bmp = BitmapFactory.decodeByteArray(b, 0, b.length);
ImageView image = (ImageView) findViewById(R.id.imageView1);
image.setImageBitmap(bmp);

Baca Selengkapnya ....

Custom GridView in Android

Posted by Unknown 0 komentar
in xml file:


< ?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
< GridView
android:id="@+id/gridView1"
android:numColumns="auto_fit"
android:gravity="center"
android:columnWidth="50dp"
android:stretchMode="columnWidth"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

< /GridView>
< /LinearLayout>
in cus_gridview file :

< ?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp" >

< ImageView
android:id="@+id/grid_item_image"
android:layout_width="50px"
android:layout_height="50px"
android:layout_marginRight="10px"
android:src="@drawable/ic_launcher">
< /ImageView>

< TextView
android:id="@+id/grid_item_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:layout_marginTop="5dp"
android:textColor="#FFFFFF"
android:textSize="16dp" >
< /TextView>
< /LinearLayout>
in java file:

public class SendCard extends Activity {
GridView gridView;
static final String[] Card = new String[] { "Card1","Card2","Card3", "Card4" };
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.send_card);

gridView = (GridView) findViewById(R.id.gridView1);
gridView.setAdapter(new ImageAdapter(this, Card));
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v,int position, long id) {

Toast.makeText(getApplicationContext(),((TextView)v.findViewById(R.id.grid_item_label))
.getText(), Toast.LENGTH_SHORT).show();
}
});

}}
in Custom Adapter Class:

public class ImageAdapter extends BaseAdapter {
private Context context;
private final String[] mobileValues;
public ImageAdapter(Context context, String[] mobileValues) {
this.context = context;
this.mobileValues = mobileValues;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView;
if (convertView == null) {
gridView = new View(context);
gridView = inflater.inflate(R.layout.cus_gridview, null);
TextView textView = (TextView)gridView.findViewById(R.id.grid_item_label);
textView.setText(mobileValues[position]);
ImageView imageView = (ImageView)

gridView.findViewById(R.id.grid_item_image);
String mobile = mobileValues[position];
if (mobile.equals("Card1")) {
imageView.setImageResource(R.drawable.icon);
} else if (mobile.equals("Card2")) {
imageView.setImageResource(R.drawable.icon);
} else if (mobile.equals("Card3")) {
imageView.setImageResource(R.drawable.icon);
} else {
imageView.setImageResource(R.drawable.icon);
}
} else {
gridView = (View) convertView;
}

return gridView;
}
public int getCount() {
return mobileValues.length;
}

public Object getItem(int position) {
return null;
}

public long getItemId(int position) {
return 0;
}}


Baca Selengkapnya ....

GridView in Android

Posted by Unknown 0 komentar
in xml file:

< pre class="brush: java"<
< ?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
< GridView
android:id="@+id/gridView1"
android:numColumns="auto_fit"
android:gravity="center"
android:columnWidth="50dp"
android:stretchMode="columnWidth"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

< /GridView>
< /LinearLayout>
in java file:

public class Gridviewactivity extends Activity {
GridView gridView;
static final String[] numbers = new String[] {
"A", "B", "C", "D", "E",
"F", "G", "H", "I", "J",
"K", "L", "M", "N", "O",
"P", "Q", "R", "S", "T",
"U", "V", "W", "X", "Y", "Z"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

gridView=(GridView) findViewById(R.id.gridView1);
ArrayAdapter adapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1,numbers);
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView arg0, View v, int position,long arg3)
{
Toast.makeText(getApplicationContext(),
((TextView) v).getText()+ "at position"+position, Toast.LENGTH_SHORT).show();
}

});
}}

Baca Selengkapnya ....
Categories: , , , , , ,

Creating A Customized ListView in Android

Posted by Unknown Jumat, 04 Januari 2013 0 komentar
Listview is simply a group of view that displays a list of scrolling items. "Adapters" are used to insert list items to the list.By default we are able to provide only text as list items.In order to insert other attributes make a customized listview. Copy or download this javacode and try yourself.
Also see here :
java file :
public class CustomListView extends Activity {
static final String[] items = new String[]{"Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday",""Saturday"};
ListView listview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
listview=(ListView) findViewById(R.id.list);
listview.setAdapter(newCustomListViewAdapter
(this,items));
listview .setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView
arg0, View arg1,int position,long arg3)
{
String value = listview.getItemAtPosition(position).toString();
System.out.println("=============>>>"+value);
}});
} }
xml file: (main)
< RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/redbg">
< ListView
android:layout_marginTop="100dp"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
< /RelativeLayout>
CustomAdapter Class:
public class CustomListViewAdapter extends ArrayAdapter {
private final Context context;
private final String[] values;

public CustomListViewAdapter(Context context, String[] values)
{
super(context, R.layout.list_view, values);
this.context = context;
this.values = values;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)

{
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.list_view, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.title);
ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
textView.setText(values[position]);
// Change icon based on name
String s = values[position];
System.out.println(s);
return rowView;
}}
xml for customizing each row:(list_view)
   < ?xml version="1.0" encoding="utf-8"?> 
< RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

< ImageView
android:id="@+id/icon"
android:src="@drawable/heartz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp" />

< TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/icon"
android:paddingBottom="10dp"
android:textColor="#FFFFFF"
android:textSize="16dp" />

< /RelativeLayout>



Baca Selengkapnya ....

Simple ListView in Android

Posted by Unknown 0 komentar
xml page:eazy_list
< RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
< ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

< /ListView>
< /RelativeLayout>
java page:
 public class MainActivity extends ListActivity 

{
String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars",
"Jupiter", "Saturn", "Uranus", "Neptune","Ceres","Pluto"};
ListView lstv;
private ArrayAdapter listAdapter ;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lstv=getListView();
listAdapter = new ArrayAdapter(this,android.R.layout.simple_expandable_list_item_1, planets);
setListAdapter(listAdapter);
}}

Baca Selengkapnya ....

Global IT spending to reach $3.7 trillion in 2013: Gartner

Posted by Unknown Kamis, 03 Januari 2013 0 komentar

 Worldwide IT spending is projected to reach $3.73 trillion in 2013, a 4.2 percent increase from $3.58 trillion in 2012, research firm Gartner Thursday said.
The 2013 outlook for IT spending growth in US dollars has been revised upward from 3.8 percent in the Q3 2012 forecast, Gartner said in a statement.
Much of this spending increase is the result from projected gains in the value of foreign currencies versus the dollar, it said adding that in constant currency, spending growth in 2013 is expected to be 3.9 percent.
"Uncertainties surrounding prospects for an upturn in global economic growth are the major retardants to IT growth.
This uncertainty has caused the pessimistic business and consumer sentiment throughout the world," Gartner Managing Vice President Richard Gordon said.
However, much of this uncertainty is nearing resolution, and as it does, Gartner expects accelerated spending growth in 2013 compared to 2012, he added.
Worldwide devices spending which includes PCs, tablets, mobile phones and printers, is forecast to reach USD 666 billion in 2013, up 6.3 percent from 2012.

readmore:
http://gadgets.ndtv.com/mobiles/news/global-it-spending-to-reach-37-trillion-in-2013-gartner-312923

Baca Selengkapnya ....
Categories: , ,

Getting the Number of Children in a Group (Size)

Posted by Unknown 0 komentar
Sample code to get the size of groups in corona :

for i=1, group.numChildren do
local child = group[i]
local description = (child.isVisible and "visible") or "not visible"
print( "child["..i.."] is " .. description )
end

Baca Selengkapnya ....

Working with images in Corona

Posted by Unknown 0 komentar
Loading an Image :
syntax:
display.newImage( filename [, baseDirectory] [, left, top] )
example:
newImage = display.newImage( "image.png", 10, 20 ) myImage2 = display.newImage( "image.png" )
Image Autoscaling:
The default behavior of display.newImage() is to auto-scale large images.To control manually we can use boolean value.
syntax:
display.newImage( [parentGroup,] filename [, baseDirectory] [, x, y] [,isFullResolution] )
example:
newImage = display.newImage( "image.png", 10, 20, true )
Images with Dynamic Resolution :
syntax:
display.newImageRect( [parentGroup,] filename [, baseDirectory] w,h )
example:
newImage = display.newImageRect( "Image.png", 100, 100 )

Baca Selengkapnya ....

Display hello world without using semicolon

Posted by Unknown 0 komentar

#include<stdio.h>
void main(){
if(printf("Hello world")){
}
}

Baca Selengkapnya ....

Calculate Quadratic equation in c language

Posted by Unknown 0 komentar
Simple program to get Quadratic equation in c language

#include< stdio.h>
#include< math.h>
int main(){
float a,b,c;
float d,root1,root2;

printf("Enter a, b and c of quadratic equation: ");
scanf("%f%f%f",&a,&b,&c);
d = b * b - 4 * a * c;
if(d < 0){
printf("The roots are complex number.\n");
printf("The roots of quadratic equation are: ");
printf("%.3f%+.3fi",-b/(2*a),sqrt(-d)/(2*a));
printf(", %.3f%+.3fi",-b/(2*a),-sqrt(-d)/(2*a));
return 0;
}
else if(d==0){
printf("Both the roots are equal.\n");
root1 = -b /(2* a);
printf("The root of quadratic equation is: %.3f ",root1);
return 0;
}
else{
printf("The roots are real numbers.\n");
root1 = ( -b + sqrt(d)) / (2* a);
root2 = ( -b - sqrt(d)) / (2* a);
printf("The roots of quadratic equation are: %.3f , %.3f",root1,root2);
}
return 0;
}
Sample output:
Enter a, b and c of quadratic equation: 2 4 1
The roots are real numbers.
The roots of quadratic equation are: -0.293, -1.707

Baca Selengkapnya ....

Long Integer Literal in java

Posted by Unknown 0 komentar
Simple program to explain Long integer literal in java.

public class MainClass {
public static void main(String[] a){
long longValue = 123456789L;
System.out.println(longValue);
}
}

Baca Selengkapnya ....

Tech Apple admits flaw in Do Not Disturb feature, will be fixed after 7 Jan

Posted by Unknown 0 komentar
 

It’s now confirmed that Apple’s Do Not Disturb feature which is available for iPhone, iPod Touch and iPad on iOS 6 doesn’t work. The buzz first started on MacRumours, where users complained that the Do Not Disturb was working ahead of the time that they had set it for.

Read more from here


http://www.firstpost.com/tech/apple-admits-flaw-in-do-not-disturb-feature-will-be-fixed-after-7-jan-576817.html 

Baca Selengkapnya ....
Categories: , , ,

Flipboard 1.9.17 apk for Galaxy Y, Galaxy Y Duos & lite, Galaxy Music.

Posted by Unknown Rabu, 02 Januari 2013 0 komentar
Hey Guys,

This is the admin of this blog (mTz),
First of all, I am really sorry for keeping this thing inactive since months, but I will finally be posting something here.

I have also done a video, check it out below 0  (that's a bonus :P)
if you can't watch the video, click here - https://www.youtube.com/watch?v=qFTZVMKPuYU



Now here's a description - 

Flipboard brings together world news and social news in a beautiful magazine
designed for your Android phone and tablet. Once you pick a few topics, your Flipboard is built and you can instantly start flipping through the pages of news you care about and stories and photos friends are sharing. Flip through the news from your Twitter timeline as well as from outlets like the BBC, USA Today and The Verge. See everything from posts and photos shared by friends on Facebook and Instagram to videos from YouTube and pop culture nuggets from Rolling Stone. Find inspiration for your travel, style and life from places like National Geographic, Oprah and Cool Hunting.
Bring Flipboard on the train during your morning commute, catch up over coffee or on vacation, use it as a tool at work or simply to wind down your night. Search for anything or anyone, and make it your own.
It’s the one thing to simplify your daily life.
Highlights:
★ With news and social networks all in one place, it’s easy to quickly catch up on the news you care about.
★ Search for anything—people, topics, hashtags, blogs, your favorite sites—and flip through articles, updates, photos and videos in a beautiful magazine format.
★ Connect Flipboard to up to 12 social networks, streamlining your reading and activities like commenting, liking and sharing. Services include Twitter, Facebook, Instagram, Google+, YouTube, Google Reader, LinkedIn, Flickr, 500px, Sina Weibo and Renren.
★ Use Cover Stories, a custom tile on Flipboard that gives you the best of everything you follow on Flipboard. Cover Store is a quick dose of what’s happening now a constantly updated selection of articles, photos and videos shared by your friends.
★ Save anything to read later using Instapaper, Pocket and Readability.
★ Create a Flipboard account to access your favorite content and social networks on different or shared devices.
★ Enjoy Flipboard in 15 localized editions—for Australia, Brazil, Canada, China, France, Germany, Hong Kong, Italy, Japan, Korea, Netherlands, Spain, Taiwan, U.S. and U.K.
★ Explore hundreds of staff picks in the Content Guide, including must-read magazines and blogs, gorgeous photography and special curated sections devoted to the news of the day and other topics of interest.
★ Access Flipboard quickly through the widget.

Download from here - HERE
Like, comment, share this post and the video to motivate us for doing more.
Thanks - mTz!



Baca Selengkapnya ....
Categories:
Postingan Lebih Baru » « Postingan Lama Beranda
Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android populer.