Where Eclipse stored Settings and Templates Java Code
C:\documents\workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.ui.prefs
396LW NO topic_id
AD
Další témata ....(Topics)
How change background color of View Android sample.
MainActivity.java
main.xml
MainActivity.java
public class MainActivity extends Activity {
TextView hTextView;
TableRow hTableRow;
Button hButton, hButtonStop;
private Handler mHandler = new Handler();
private int nCounter = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
hTextView = (TextView)findViewById(R.id.idTextView);
hButton = (Button)findViewById(R.id.idButton);
hButton.setOnClickListener(mButtonStartListener);
hTableRow = (TableRow)findViewById(R.id.idTableRow1);
} // end onCreate
View.OnClickListener mButtonStartListener = new OnClickListener() {
public void onClick(View v) {
hTableRow.setBackgroundColor(Color.YELLOW);
}
};
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/tableLayout1">
<TableRow android:id="@+id/idTableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="#5655AA">
<TextView
android:id="@+id/idTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</TableRow>
</TableLayout>
</LinearLayout>
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
private static class SampleView extends View {
// CONSTRUCTOR
public SampleView(Context context) {
super(context);
setFocusable(true);
}
@Override
protected void onDraw(Canvas canvas) {
Paint paint = new Paint();
canvas.drawColor(Color.YELLOW);
Bitmap b = Bitmap.createBitmap(200, 200,
Bitmap.Config.ARGB_8888);
// you need to insert a image flower_blue into res/drawable folder
paint.setFilterBitmap(true);
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
R.drawable.flower_blue);
canvas.drawBitmap(bitmapOrg, 10, 10, paint);
int width, height;
Canvas c = new Canvas(b);
paint.setAlpha(255); //0x80
c.translate(0, 30);
c.drawBitmap(bitmapOrg, new Matrix(), paint);
paint.setColor(Color.BLUE);
Path mPath = new Path();
mPath.addCircle(50, 50, 50, Path.Direction.CCW);
//c.clipPath(mPath, Region.Op.UNION);
//c.clipPath(mPath, Region.Op.DIFFERENCE);
c.clipPath(mPath, Region.Op.INTERSECT);
//c.clipPath(mPath, Region.Op.REPLACE);
//c.clipPath(mPath, Region.Op.XOR);
paint.setColor(Color.GREEN);
paint.setAntiAlias(true);
c.drawCircle(30, 20, 30, paint);
int h = bitmapOrg.getHeight();
//canvas.drawBitmap(bitmapOrg, 10, 10, paint);
canvas.drawBitmap(b, 0, 10 + h + 10, paint);
}
}
}
entry put iterate Map HashMap Java Android
Map<String, Integer> map = new HashMap<String, Integer>();
map.put("key27", 27);
for (Map.Entry<String, Integer> entry : map.entrySet())
{
String str = entry.getKey();
int n = entry.getValue();
}
private int[] mData = new int[2]; // fill some values into array!!
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean("myBoolean", true);
outState.putDouble("myDouble", 2.7);
outState.putInt("myInt", 5);
outState.putString("myString", "Heloo girls!");
int[] data = new int[mData.length];
for (int i = 0; i < data.length; i++) {
data[i] = mData[i];
}
outState.putIntArray("myArray", data);
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
boolean myBoolean = savedInstanceState.getBoolean("myBoolean", false); // false basic value
double myDouble = savedInstanceState.getDouble("myDouble", 1.5); // 1.5 basic value
int myInt = savedInstanceState.getInt("myInt", 10);
String myString = savedInstanceState.getString("myString", "Hello boys!");
int[] data = savedInstanceState.getIntArray("myArray");
if (data != null && data.length == mData.length) {
for (int i = 0; i < data.length; i++) {
mData[i] = data[i];
}
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean myBoolean = savedInstanceState != null ? savedInstanceState.getBoolean("myBoolean", false) : true;
// etc. .......
}
Try this solutions:
1.) Save xml file
2.) Close tab with xml file
3.) Reopen xml file
1.) Open from menu Window->Android SDK Manager
2.) Select available updates (Tools, SDK etc.)
3.) Install updates
1.) Open from menu Help->Check for Updates
2.) Install available plugins what You need
3.) Restart Eclipse
1.) Save xml file
2.) Close tab with xml file
3.) Reopen xml file
1.) Open from menu Window->Android SDK Manager
2.) Select available updates (Tools, SDK etc.)
3.) Install updates
1.) Open from menu Help->Check for Updates
2.) Install available plugins what You need
3.) Restart Eclipse
Editace: 2014-04-03 12:45:26
Počet článků v kategorii: 396
Url:where-eclipse-stored-templates-java-code