This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check the condition as | |
if (android.os.Build.VERSION.SDK_INT>=11){ | |
//Do something | |
} | |
// This is better | |
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){ | |
//Do something | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//When the class extends from Activity | |
ActionBar actionBar = getActionBar(); | |
actionBar.hide(); //hide | |
actinBar.show(); //Show | |
//When the class extends from AppCompatActivity | |
getSupportActionBar().hide(); //hide | |
getSupportActionBar().show(); //show | |
//In FragmentActivity, you need to change the FragmentActivity to an ActionBarActivity, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// String resource. normal method | |
btnRutas.setText(R.string.rutas); | |
// Get resources dynamically. When string variable is different in some cases | |
String variable = ruta.getDescripcion(); //For example, now variable is "car_description" | |
int intVariableForTranslate = context.getResources().getIdentifier(variable, "string", context.getPackageName()); | |
String descriptionTranslated = context.getString(intVariableForTranslate); | |
// String resource | |
String myString = getResources().getString(R.string.mystring) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//First activity (ActivityA). The data is in editText (et1) | |
Intent i = new Intent(this, ActivityB.class); | |
i.putExtra("textByUser", et1.getText().toString()); | |
startActivity(i); | |
//Second activity (ActivityB). Get data | |
Bundle bundle = getIntent().getExtras(); | |
String data = bundle.getString("textByUser"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gunhansancar.android.sdk.helper; | |
import android.content.Context; | |
import android.content.SharedPreferences; | |
import android.content.res.Configuration; | |
import android.content.res.Resources; | |
import android.preference.PreferenceManager; | |
import java.util.Locale; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gunhansancar.android.example.application; | |
import android.app.Application; | |
import com.gunhansancar.android.sdk.helper.LocaleHelper; | |
/** | |
* When your application is launched this class is loaded before all of your activies. | |
* And the instance of this class will live through whole application lifecycle. | |
* <p/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gunhansancar.android.example.activity; | |
import android.content.res.Resources; | |
import android.support.v7.app.AppCompatActivity; | |
import android.widget.TextView; | |
import com.gunhansancar.android.example.R; | |
import com.gunhansancar.android.sdk.helper.LocaleHelper; | |
import butterknife.Bind; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [ES] Hilo dormilón | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.TextView; | |
public class ThreadSleepyheadIndependentClass extends AppCompatActivity { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [ES] Hilo dormilón | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.TextView; | |
public class ThreadSleepyhead extends AppCompatActivity { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [EU] Hari berdinean (app-aren hari nagusia) interfaze aldaketa burutzeko. Kasu honetan | |
// TextView baten aldaketa | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.TextView; |
OlderNewer