AndroidStudio Live Templates 요약

5883 단어

1. 안드로이드


const####

private static final int $name$ = $value$;

fbc####

($cast$) findViewById(R.id.$resId$);

foreach####

for ($i$ : $data$) {    $cursor$}

gone####

$VIEW$.setVisibility(android.view.View.GONE);

IntentView####

android.content.Intent view = new Intent();
view.setAction(Intent.ACTION_VIEW);
view.setData(android.net.Uri.parse($url$));
startActivity(view);

key####

private static final String KEY_$value$ = "$value$";

newInstance####

public static $fragment$ newInstance($args$) {
    $nullChecks$
    android.os.Bundle args = new Bundle();
    $addArgs$
    $fragment$ fragment = new $fragment$();
    fragment.setArguments(args);
    return fragment;
}

noInstance####

private $class$() {
    //no instance
}

rgS####

$resources$.getString(R.string.$stringId$)

rouiT####

getActivity().runOnUiThread(new java.lang.Runnable() {
    @Override
    public void run() {
        $cursor$
    }
});

sbc####

///////////////////////////////////////////////////////////////////////////
// $blockName$
///////////////////////////////////////////////////////////////////////////

Sfmt####

String.format("$string$", $params$);

starter####

public static void start(android.content.Context context) {
    android.content.Intent starter = new Intent(context, $ACTIVITY$.class);
    starter.putExtra($CURSOR$);
    context.startActivity(starter);
}

Toast####

android.widget.Toast.makeText($className$.this, "$text$", Toast.LENGTH_SHORT).show();

ViewConstructors####

public $class$(android.content.Context context) {
    this(context, null);
}

public $class$(Context context, android.util.AttributeSet attrs) {
    this(context, attrs, 0);
}

public $class$(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    $cursor$
}

visible####

$VIEW$.setVisibility(View.VISIBLE);

wrapIt####

task wrapper(type: Wrapper) {
    gradleVersion = "$version$"
}

2. AndroidParcelable


Parcelable####

protected $className$(android.os.Parcel in) {
  
}
  
@Override
public int describeContents() {
  return 0;
}

@Override
public void writeToParcel(@android.support.annotation.NonNull android.os.Parcel dest, int flags) {
  
}

public static final android.os.Parcelable.Creator CREATOR = new Parcelable.Creator() {
  @Override
  public $className$ createFromParcel(Parcel in) {
    return new $className$(in);
  }

  @Override
  public $className$[] newArray(int size) {
    return new $className$[size];
  }
};

ParcelableEnum####

@Override
public int describeContents() {
  return 0;
}

@Override
public void writeToParcel(android.os.Parcel dest, int flags) {
  dest.writeInt(this.ordinal());
}
   
public static final android.os.Parcelable.Creator CREATOR = new Parcelable.Creator() {
  @Override
  public $className$ createFromParcel(Parcel in) {
    return $className$.values()[in.readInt()];
  }

  @Override
  public $className$[] newArray(int size) {
    return new $className$[size];
  }
};

ParcelableEnumTest####

@Test
public void testDescribeContents() throws Exception {
  for ($className$ value : $className$.values()) {
    assertEquals(0, value.describeContents());
  }
}

@Test
public void testWriteToParcel() throws Exception {
  Parcel parcel;
  for ($className$ value : $className$.values()) {
    parcel = Parcel.obtain();

    Parcel parceled$className$ = ParcelableHelper.writeToParcelAndResetDataPosition(value, 0);
    value.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);

    $className$ unparceled$className$ = $className$.CREATOR.createFromParcel(parceled$className$);
    assertEquals(value, unparceled$className$);
  }
}

@Test
public void testArrayParcelable() throws Exception {
  $className$[] values = $className$.CREATOR.newArray($className$.values().length);
  assertEquals($className$.values().length, values.length);
}

ParcelBoolean####

dest.writeInt($bool$ ? 0 : 1);

UnparcelBoolean####

$bool$ = 0 == in.readInt();

UnparcelIntArray####

int $read$[] = in.createIntArray();in.readIntArray($read$);

UnparcelStringArray####

String $read$[] = in.createStringArray();in.readStringArray($read$);

3. 안드로이드XML


appNs####

xmlns:app="http://schemas.android.com/apk/res-auto"

lh####

android:layout_height="$height$"

lhm####

android:layout_height="match_parent"

lhw####

android:layout_height="wrap_content"

lw####

android:layout_width="$width$"

lwm####

android:layout_width="match_parent"

lww####

android:layout_width="wrap_content"

toolsNs####

xmlns:tools="http://schemas.android.com/tools"

좋은 웹페이지 즐겨찾기