R.java not generated - Android project in Eclipse issue
If You create new xml file with prefix _ , for example _style.xml and You to clean project (Project->Clean), than package in folder project\gen will deleted with R.java class and new R.java not be created.
For to solving this problem You have to rename file without prefix _ as style.xml or name what You need and rebuild project.
If some ID cannot be resolved or is not a field get error occurence
You have to delete import android.R; in Activity.class if was inserted,
when this error is displayed.
For to solving this problem You have to rename file without prefix _ as style.xml or name what You need and rebuild project.
If some ID cannot be resolved or is not a field get error occurence
You have to delete import android.R; in Activity.class if was inserted,
when this error is displayed.
396LW NO topic_id
AD
Další témata ....(Topics)
Java double is 64 bit double precision type used when fractional
precision calculation is required.
Java double je datový typ (reálné číslo) o velikosti 64 bitů. Používá se například pro přesný výsledek po dělení za desetinnou tečkou. Pokud nepotřebuje tak veliké číslo použijte raději typ float, šetříte tím paměť mobilního telefonu.
precision calculation is required.
Java double je datový typ (reálné číslo) o velikosti 64 bitů. Používá se například pro přesný výsledek po dělení za desetinnou tečkou. Pokud nepotřebuje tak veliké číslo použijte raději typ float, šetříte tím paměť mobilního telefonu.
// declaration and assignment of value type double
double x = 18.41785;
//print formated value
System.out.printf("The value of x is %.3f%n", x); // 18.418
// declaring more variables in single statement
double d1 = 12.4, d2 = 564.5, d3 = 14.589;
// double range of value
System.out.println(Double.MIN_VALUE); // 4.9E-324
System.out.println(Double.MAX_VALUE); // 1.7976931348623157E308
// is NaN Not-a-Number
double f = (double) Math.sqrt(-15);
boolean bNaN = Double.isNaN(f);
System.out.print(bNaN); // true
// check if a string is a valid number in Java example
// convert string to double Java example
String sD = "12.8";
double dParse = Double.parseDouble(sD);
// convert strings to numbers
String sDl = "15.48";
double dFromString = (Double.valueOf(sDl)).doubleValue();
// format double, float or long value to string
DecimalFormat formatter = new DecimalFormat(".##");
String s = formatter.format(-.5678); // -0.57
// .### -0.568
// .#### -0.5678
// .000000 -.567800
// -123.456
// .## -123.46
// #.## -123.46
// #E0 -.1E3
// ##E0 -1.2E2
//###E0 -123E0
// double to string in Java example code
Double dObj = new Double(68.5);
String str = dObj.toString();
// else
Double dS = 11.6;
String sdouble = dS.toString();
// compare two double variables
Double dComp1 = 4.3;
if(dComp1.equals(4.3))
System.out.print("true");
// compares the two specified double values in Java example
// int i = compare(double d1, double d2);
int i = Double.compare(11.5, 11.7); // -1 first < second
// 0 first == second
// 1 first > second
System.out.print(i);
Hashtable find value by key Java Android basic example.
import java.util.Hashtable;
public class MainClass {
public static void main(String[] arg) {
// english;germany dictionary
String[] arrayOfString = { "one;eine", "two;zwei", "three;drei" };
Hashtable hashTable = new Hashtable();
for(String s: arrayOfString){
String[] array = s.split(";");
String sKey ="", sValue="";
if(array.length > 1){
sKey = array[0]; sValue = array[1];
hashTable.put(sKey, sValue);
}
}
// check if key exists
if( hashTable.containsKey("two")){
System.out.print("two = " + hashTable.get("two"));
}
}
}
/*
two = zwei
*/
Cross Button in EditText Android for deleting clearing text in EditText Example source code:
Example allow delete text in EditText by cross button, or do Button click performance.
main.xml type your package name and class
Put into drawable folder cross and ok image.
CustomEditText.java
YourActivity.java
//android.okhelp.cz/wiktionary-aplikace-pro-android/
Example allow delete text in EditText by cross button, or do Button click performance.
main.xml type your package name and class
Put into drawable folder cross and ok image.
<cz.okhelp.wiktionary.CustomEditText
android:id="@+id/editTextZadejSlovo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:ems="10"
android:hint="TypeAndPressGreen"
android:singleLine="true"
android:lines="1"
android:maxLines="1"
android:drawableLeft="@drawable/cross"
android:drawableRight="@drawable/ok" />
<!--button is invisible 0 height 0 width for performance click on button in EditText-->
<Button
android:id="@+id/btnGO"
android:layout_width="0sp"
android:layout_height="0sp"
android:layout_weight="0"
android:text="GO" />
CustomEditText.java
package cz.okhelp.wiktionary; // your package name
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.Button;
import android.widget.EditText;
public class CustomEditText extends EditText
{
private Drawable dLeft,dRight;
private Rect lBounds,rBounds;
private static Button btnOk;
public CustomEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public CustomEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomEditText(Context context) {
super(context);
}
@Override
public void setCompoundDrawables(Drawable left, Drawable top,
Drawable right, Drawable bottom)
{
if(left !=null) {
dLeft = left;
}
if(right !=null){
dRight = right;
}
super.setCompoundDrawables(left, top, right, bottom);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
btnOk.requestFocus();
btnOk.performClick();
}
return super.onKeyUp(keyCode, event);
}
@Override
public boolean onTouchEvent(MotionEvent event)
{
final int x = (int)event.getX();
final int y = (int)event.getY();
if(event.getAction() == MotionEvent.ACTION_UP && dLeft!=null) {
lBounds = dLeft.getBounds();
int n1 = this.getLeft();
int n2 = this.getLeft()+lBounds.width();
int n3 = this.getPaddingTop();
int n4 = this.getHeight()-this.getPaddingBottom();
// leva strana
if( x>=(this.getLeft())
&& x<=(this.getLeft()+lBounds.width())
&& y>=this.getPaddingTop()
&& y<=(this.getHeight()-this.getPaddingBottom()))
{
this.setText("");
event.setAction(MotionEvent.ACTION_CANCEL);//use this to prevent the keyboard from coming up
}
}
if(event.getAction() == MotionEvent.ACTION_UP && dRight!=null)
{
rBounds = dRight.getBounds();
int n1 = this.getRight()-rBounds.width();
int n2 = this.getRight()-this.getPaddingRight();
int n3 = this.getPaddingTop();
int n4 = this.getHeight()-this.getPaddingBottom();
// prava strana
if(x>=(this.getRight()-rBounds.width()) && x<=(this.getRight()-this.getPaddingRight())
&& y>=this.getPaddingTop() && y<=(this.getHeight()-this.getPaddingBottom()))
{
btnOk.requestFocus();
btnOk.performClick();
event.setAction(MotionEvent.ACTION_CANCEL);//use this to prevent the keyboard from coming up
}
}
return super.onTouchEvent(event);
}
@Override
protected void finalize() throws Throwable
{
dRight = null;
rBounds = null;
super.finalize();
}
public void setBtnOk(Button btnOk) {
this.btnOk = btnOk;
}
public Button getBtnOk() {
return btnOk;
}
}
YourActivity.java
//onCreate
Button mBtnGO = (Button)findViewById(R.id.btnGO);
CustomEditText mEditZadani = (CustomEditText)this.findViewById(R.id.editTextZadejSlovo);
mEditZadani.setBtnOk(mBtnGO);
mBtnGO.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// do stuff for signInButtonClick
}
});
//android.okhelp.cz/wiktionary-aplikace-pro-android/
HashMap<String,Locale> _mapOfLocale = new HashMap<String,Locale>();
_mapOfLocale.put("French",Locale. FRENCH );
_mapOfLocale.put("German",Locale. GERMAN );
_mapOfLocale.put("Italian",Locale. ITALIAN );
for (Entry<String, Locale> entry : _mapOfLocale.entrySet()) {
System.out.println(entry.getKey());
System.out.println(entry.getValue());
}
Add and shuffle elements in LinkedList or ArrayList Java basic example.
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = {"nothing", "Hello", "people"
, "bye-bye", "hello", "world!", "End" };
List<String> arrayList = new LinkedList<String>();
for(String s: arrayOfString)
arrayList.add(s);
Collections.shuffle(arrayList);
System.out.println(arrayList);
}
}
/*
[hello, world!, bye-bye, nothing, people, End, Hello]
*/
Editace: 2014-02-15 20:34:49
Počet článků v kategorii: 396
Url:r-java-not-generating-android-project-in-eclipse-issue