If you get the error of "Type R cannot be resolved to a variable" after Android SDK and ADT updated. Try to find and install any available update in Android SDK.
In my case, after update Android SDK Tools rev 22, and also ADT. I get error of "Type R cannot be resolved to a variable" in my projects, and any new project!
- Start Android SDK Manager again. Two more update available, Android SDK Platform-tools and Android SDK Build-tools. It was not available in the previous update.
- Install the update packages.
- Close and restart Eclipse.
- Problem solved.
Android-er
Wednesday, May 22, 2013
Tegra Android Development Pack
The Tegra Android Development Pack 2.0 installs all software tools required to develop for Android on NVIDIA’s Tegra platform. This suite of developer tools is targeted at Tegra devices, but will configure a development environment that will work with almost any Android device. This cure for the common cold is available on Windows, OSX, Ubuntu Linux 32-bit and Ubuntu Linux 64-bit.
To Download The Files Below, you must be a member of the Tegra Registered Developer Program. To join simply create a new account (it's free and easy).

To Download The Files Below, you must be a member of the Tegra Registered Developer Program. To join simply create a new account (it's free and easy).
Monday, May 20, 2013
Apply animations on layout changes using LayoutTransition
LayoutTransition (Added in API level 11) enables automatic animations on layout changes in ViewGroup objects.
example:
LayoutTransition transition = new LayoutTransition();
container.setLayoutTransition(transition);
It's the default animations effect apply on the dynamic view in last exercise "Add and Remove view dynamically".
Modify MainActivity.java from last exercise.
- Apply LayoutTransition on container of LinearLayout.
- To made the effect noticeable, insert dynamic view in front by calling container.addView(addView, 0) instead of container.addView(addView).
- Modify AndroidManifest.xml to have minSdkVersion="11".
Download the files.
example:
LayoutTransition transition = new LayoutTransition();
container.setLayoutTransition(transition);
It's the default animations effect apply on the dynamic view in last exercise "Add and Remove view dynamically".
Modify MainActivity.java from last exercise.
- Apply LayoutTransition on container of LinearLayout.
- To made the effect noticeable, insert dynamic view in front by calling container.addView(addView, 0) instead of container.addView(addView).
- Modify AndroidManifest.xml to have minSdkVersion="11".
package com.example.androiddynamicview;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.animation.LayoutTransition;
import android.app.Activity;
import android.content.Context;
public class MainActivity extends Activity {
EditText textIn;
Button buttonAdd;
LinearLayout container;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textIn = (EditText)findViewById(R.id.textin);
buttonAdd = (Button)findViewById(R.id.add);
container = (LinearLayout)findViewById(R.id.container);
buttonAdd.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
LayoutInflater layoutInflater =
(LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View addView = layoutInflater.inflate(R.layout.row, null);
TextView textOut = (TextView)addView.findViewById(R.id.textout);
textOut.setText(textIn.getText().toString());
Button buttonRemove = (Button)addView.findViewById(R.id.remove);
buttonRemove.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
((LinearLayout)addView.getParent()).removeView(addView);
}});
container.addView(addView, 0);
}});
LayoutTransition transition = new LayoutTransition();
container.setLayoutTransition(transition);
}
}
Subscribe to:
Posts (Atom)

