Skip to content

Instantly share code, notes, and snippets.

View akbarsha03's full-sized avatar
🎯
I just keep trying

Akbarsha M akbarsha03

🎯
I just keep trying
View GitHub Profile
@akbarsha03
akbarsha03 / ButtonActivity1.java
Last active December 28, 2015 00:19
#1 How to define and initialize a button in Android - way 1
package com.blogspot.pcnlap.elegant;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
@akbarsha03
akbarsha03 / ButtonActivity2.java
Last active December 28, 2015 00:19
#2 How to define and initialize a button in Android - way 2
package com.blogspot.pcnlap.elegant;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
@akbarsha03
akbarsha03 / ButtonActivity3.java
Last active December 28, 2015 00:19
#3 How to initialize a button in Android - way 3 (Simplest way)
package com.blogspot.pcnlap.elegant;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
@akbarsha03
akbarsha03 / TimePickerForAlarm
Created February 18, 2014 07:34
Use TimePickerDialog to get time from the user
// Use a `TimePickerDialog` to get the `runDelay` from user to do so
// **class variable:**
private TimePickerDialog time_picker;
private Calendar targetCal;
// **A class constructor**
@akbarsha03
akbarsha03 / SetTabHostHeight
Created February 18, 2014 07:51
Set height for Tab in TabHost
public class TipoDisp
{
public static int alt_tabs(Context cont)
{
int alt;
int dx, dy;
DisplayMetrics metrics = cont.getResources().getDisplayMetrics();
@akbarsha03
akbarsha03 / RecordExistOrNot.java
Created June 13, 2014 10:10
Check DB if a record is already exist or not
public boolean Exists(String _id) {
Cursor cursor = mDb.rawQuery("select 1 from yourTable where _id=?",
new String[] { _id })
boolean exists = (cursor.getCount() > 0);
cursor.close();
return exists;
}
@akbarsha03
akbarsha03 / comments.xml
Last active August 29, 2015 14:03
This is how to create the table in JavaDoc
The type of navigation to use.
<p>Must be one of the following constant values.</p>
<table>
<colgroup align="left" />
<colgroup align="left" />
<colgroup align="left" />
<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
<tr><td><code>normal</code></td><td>0</td><td> Normal static title text </td></tr>
<tr><td><code>listMode</code></td><td>1</td><td> The action bar will use a selection list for navigation. </td></tr>
<tr><td><code>tabMode</code></td><td>2</td><td> The action bar will use a series of horizontal tabs for navigation. </td></tr>
@akbarsha03
akbarsha03 / StringSplit.java
Created July 11, 2014 06:41
Split string using comma
String str = "hi,hello,abc,example,problems";
String[] splits = str.split(",");
System.out.println("splits.size: " + splits.length);
for(String asset: splits){
System.out.println(asset);
}
@akbarsha03
akbarsha03 / DynamicSize.java
Created July 15, 2014 07:03
Get required view size dynamically in percentage depends upon the Screen size
/**
* Get the area of the screen size. following calculation done with the help
* of Ashik :D
*
* @param context
* @param percentage
* @return intRequiredCellSize
* @author Ashik Ali
*/
public static int getCellSizeForScreen(Context context, double percentage) {
@akbarsha03
akbarsha03 / Languages.xml
Created July 15, 2014 11:35
All language list
<!-- All language list -->
<string-array name="languages">
<item>Afrikaans</item>
<item>Amharic</item>
<item>Arabic</item>
<item>Belarusian</item>
<item>Bulgarian</item>
<item>Catalan</item>
<item>Chinese(Simplified)</item>
<item>Chinese(Traditional)</item>