Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Rename Android project package issue in Eclipse - R cannot be resolved to a variable


AD MOB

Issue: After after renaming package this problem occurred "R cannot be resolved to a variable".

Solution: Try Clean your project Project » Clean » Clean projects selected below » select your project and click OK.

Try to delete the invalid code and type it again:

LinearLayout layout = (LinearLayout) findViewById(R.id.layout); // delete R.id.layout
LinearLayout layout = (LinearLayout) findViewById(); 
LinearLayout layout = (LinearLayout) findViewById(R.id.layout); // re-write this code R.id.layout

397LW NO topic_id




AD

Další témata ....(Topics)


135

Draw Arc Android basic example | draw-arc-android-basic-example


drawArc(), Canvas, Paint, setStyle()

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) {

			canvas.drawColor(Color.CYAN);
			Paint p = new Paint();
			// smooths
			p.setAntiAlias(true);
			p.setColor(Color.RED);
			p.setStyle(Paint.Style.STROKE); 
			p.setStrokeWidth(5);
			// opacity
			//p.setAlpha(0x80); //
 
			RectF rectF = new RectF(50, 20, 100, 80);
			canvas.drawOval(rectF, p);
			p.setColor(Color.BLACK);
			canvas.drawArc (rectF, 90, 45, true, p);
		}

	}
}

99

Essential Eclipse Shortcuts with pictures | essential-eclipse-shortcuts-with-pictures


Eclipse Navigation Shortcuts.

Keyboard_shortcuts_(3.0).pdf
Ctrl+1 Quick fix problem
eclipse-ctrl-1



Ctrl+O Quick Outline
eclipse-ctrl-o



Ctrl+Shift+G Find references in workspace
Ctrl+Shift+U Find all references in file
eclipse-ctrl-shift-u




Ctrl+Shift+T Find Java Typ

[caption id="attachment_1214" align="alignleft" width="150" caption="eclipse-ctrl-shift-t"][/caption]


Ctrl+Shift+R Find Resource



Ctrl+E Open Editor Drop-Down
Ctrl+Space Content Assist
eclipse-ctrl-space


Ctrl+Shift+Space Context Information

eclipse-ctrl-shift-space


F3 Open Declaration of variable
F4 Open Type Hierarchy
Ctrl+H Open Search Dialog
Alt+Shift+R Rename - Refactoring
Alt+Shift+M Extract Method
Alt+Shift+L Extract Local Variable

Alt Shift Up Expand selection to enclosing element
Alt Shift Right Expand selection to next element
Alt Shift Left Expand selection to previous element
Alt Shift Down Restore previous selection

Breakpoints Shift+Alt+Q B
Cheat Sheets Shift+Alt+Q H
Console Shift+Alt+Q C
Java Declaration Shift+Alt+Q D
Java Package Explorer Shift+Alt+Q P
Java Type Hierarchy Shift+Alt+Q T
Javadoc Shift+Alt+Q J
Search Shift+Alt+Q S
Show View (View: Outline)Shift+Alt+Q O
Show View (View: Problems)Shift+Alt+Q X
Synchronize Shift+Alt+Q Y
Variables Shift+Alt+Q V

214

LinkedMap HashMap Java | linkedmap-hashmap-java



Map<Float,String> linkedHashMap = new LinkedHashMap<Float, String>();

 linkedHashMap.put(14.f, "text");
 linkedHashMap.put(13.f, "text");
 linkedHashMap.put(10.f, "text");
 linkedHashMap.put(11.f, "text");
 linkedHashMap.put(2.f, "text");
 linkedHashMap.put(3.f, "text");
 linkedHashMap.put(1.f, "text");
 linkedHashMap.put(7.f, "text");
 linkedHashMap.put(23.f, "text");

	for (Entry<Float,String> entry : linkedHashMap.entrySet()) {
		System.out.println(entry.getKey());
	}
14.0
13.0
10.0
11.0
2.0
3.0
1.0
7.0
23.0

Map<Float,String> hashMap = new HashMap<Float, String>();

 hashMap.put(14.f, "text");
 hashMap.put(13.f, "text");
 hashMap.put(10.f, "text");
 hashMap.put(11.f, "text");
 hashMap.put(2.f, "text");
 hashMap.put(3.f, "text");
 hashMap.put(1.f, "text");
 hashMap.put(7.f, "text");
 hashMap.put(23.f, "text");

 
 
	for (Entry<Float,String> entry : hashMap.entrySet()) {
		System.out.println(entry.getKey());
	}
// key :
1.0
14.0
3.0
13.0
2.0
7.0
11.0
23.0
10.0


363

How rebuild only one module in project Android Studio | how-rebuild-only-one-module-in-project-android-studio


If you do click on Rebuid project menu item, this operation maybe consume long time on slovly PC.
Some errors dismis when you do rebuild project, or module.
Try this:
Select module where contains red error code and press Debugg or Run button on Android Studio.
If module code contains errors, Android Studio show error report in gradle console.
If not, apk will installed on device.
This is 10 times faster than Clean - Rebuild all project.
0

EditText text changed java Android | edittext-text-changed


Google Android example source code - is text changed in EditText ?

EditText hEditText;

// TextChanged in onCreate
hEditText = (EditText)findViewById(R.id.idEditText);
hEditText.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable str) {
}

public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}

public void onTextChanged(CharSequence sq, int start, int before,
int count) {
}
});


Editace: 2014-02-15 20:45:39
Počet článků v kategorii: 397
Url:rename-android-project-package-issue-in-eclipse

AD
11 Share
Share
Tweet