.gitignore for android

Source: http://stackoverflow.com/a/21049338/2810172

# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# built native files (uncomment if you build your own)
# *.o
# *.so

# generated files
bin/
gen/

# Ignore gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Eclipse Metadata
.metadata/

# Mac OS X clutter
*.DS_Store

# Windows clutter
Thumbs.db

# Intellij IDEA (see https://intellij-support.jetbrains.com/entries/23393067)
.idea/workspace.xml
.idea/tasks.xml
.idea/datasources.xml
.idea/dataSources.ids

Renaming your android studio project

You can do this:

  1. Change the package name manually in the manifest file.
  2. Click on your R.java class and the press F6 (Refactor->Move…). It will allow you to move the class to another package, and all references to that class will be updated.

Source: http://stackoverflow.com/questions/6600329/how-do-i-rename-the-android-package-name

 

Other links that might be useful

http://stackoverflow.com/questions/16804093/android-studio-rename-package

http://stackoverflow.com/questions/18276872/change-project-name-on-android-studio

Previewing widgets in android studio preview mode

Inflating things this way seems to work for the preview:

public FlightOutboundInbound(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    init();
}

private void init() {
    setWeightSum(3);
    setBackgroundResource(R.drawable.dark_blue_border_rect);
    setOrientation(HORIZONTAL);

    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.widget_flight_outbound_inbound, this, true);
    ButterKnife.bind(this);
}

But inflating things using the static view does not seem to work.

Source: http://stackoverflow.com/questions/17296552/preview-layout-with-merge-root-tag-in-intellij-idea-android-studio

<merge 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"
    tools:parentTag="LinearLayout"
    tools:orientation="horizontal">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Some text"
        android:textSize="20sp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Some other text"/>
</merge>

variables in the local.properties file in android studio

local.properties file

## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Aug 22 10:54:33 BST 2016
sdk.dir=C\:\\Users\\MrDevMonk\\AppData\\Local\\Android\\Sdk
addsuffix=true

and then in the app gradle you can access it using the Properties class

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def addsuffix = properties.getProperty('addsuffix')

and you can also add it in the buildConfigField

buildConfigField "boolean", "ADD_SUFFIX", addsuffix

and from your hava classes you can access it:

BuildConfig.ADD_SUFFIX