After installing Android Studio 0.5.1, you may get the below message,
The project is using an unsupported version of Gradle. Please use version 1.10
Solution for this:
Modify the gradle-wrapper.properties
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
and your build.gradle
compileSdkVersion 19
buildToolsVersion "19.0.1"
running:./gradlew clean assemble in the terminal
Saturday, April 26, 2014
Tuesday, March 11, 2014
How to add space between each controls( buttons, text box )..
There is simple way to add space between controls( buttons, text boxes..etc..) in an linear layout. Add the following attribute in the controls,
<Button
android:layout_width="280dp"
android:layout_height="40dp"
android:layout_marginTop="15dp"
/>
This will allow 15dp space above the button. Likewise you can give space between each controls. You can use the following attributes too,
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
<Button
android:layout_width="280dp"
android:layout_height="40dp"
android:layout_marginTop="15dp"
/>
This will allow 15dp space above the button. Likewise you can give space between each controls. You can use the following attributes too,
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
Sunday, January 26, 2014
Android activity title background color/image change
For changing Title bar background, add the following code in the activite's onCreate() function,
ActionBar bar = getActionBar();
//for color
//bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#DDAAD")));
//for image
bar.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_bg3));
bar.setTitle("add your own title here");
For changing the Title bar title's color,
In the onCreate() Function,
this.setTitleColor(getResources().getColor(R.color.black));
Saturday, January 18, 2014
Android Button Click Event
There are three ways to do it,
First Method,
In the onCreate function,
Second Method,
Import the following package,
import android.view.View.OnClickListener;
In onCreate method add the following Listener,
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
addListenerOnButton();
}
Implement the Listener,
Third Method,
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/self_destruct"
android:onClick="displayMap" />
when a user clicks the button, the Android system calls the activity's displayMap(View) function.
And the function declaration would be,
public void displayMap(View myview)
{
//made your own code for button click
}
First Method,
In the onCreate function,
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
ImageView iv = (ImageView) findViewById(R.id.imageview1);
iv.setVisibility(View.VISIBLE);
}
});
|
Second Method,
Import the following package,
import android.view.View.OnClickListener;
In onCreate method add the following Listener,
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
addListenerOnButton();
}
Implement the Listener,
public void addListenerOnButton() {
button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent browserIntent =
new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.vijaynetwork.com"));
startActivity(browserIntent);
}
});
|
Third Method,
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/self_destruct"
android:onClick="displayMap" />
when a user clicks the button, the Android system calls the activity's displayMap(View) function.
And the function declaration would be,
public void displayMap(View myview)
{
//made your own code for button click
}
Monday, November 25, 2013
How to override 'web site not found' message in webview control
Add the following code inside of 'onCreate(Bundle savedInstanceState)' function,
locationview.setWebViewClient(new WebViewClient()
{
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
locationview.loadUrl("file:///assets/error.html");
} });
The above URL will be load if the web page not found in the webview control.
Saturday, August 10, 2013
How to remove notification bar
Put this code in your onCreate() method,
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
How to remove title bar..
Put this in your onCreate() method.
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Subscribe to:
Posts (Atom)