On orientation changed view button textview not visible Android
Try add to AndroidManifest.xml configChanges for your Activity
android:configChanges="keyboardHidden|orientation|screenSize"
android:configChanges="keyboardHidden|orientation|screenSize"
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize"
>
396LW NO topic_id
AD
Další témata ....(Topics)
Where file(s) does eclipse store Java code style settings to?
If you need copy any old templates to the new workspace.
You can edit the Eclipse Templates from menu Window - Preferences - Java - Editor - Templates.
If you need copy any old templates to the new workspace.
workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.ui.prefs
You can edit the Eclipse Templates from menu Window - Preferences - Java - Editor - Templates.
Example source code for Android Developers
// clickable TextView
public TextView createTextView(String sText, Context con){
TextView b = null;
try {
b = new TextView (con);
b.setTextSize(15.0f);
b.setTextColor(Color.rgb( 0, 0, 200));
b.setOnClickListener(this);
b.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
b.setText(sText);
//tr.addView(b, 60,30);
} catch (Exception e) {
e.printStackTrace();
return b;
}
return b;
}
/*****************/
public void onClick(View view) {
try {
String s = ((TextView) view).getText().toString();
}
catch (Exception e1) {
e1.printStackTrace();
}
}
/***********/
// if you want restore in TextView after chagne of orientation
// you have to put code to Manifest.xml android:configChanges
activity android:name=".main"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation" //this line important !!!!!!!
Goto in for cycle Java example source code.
MainClass.java
MainClass.java
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = {"nothing", "Hello", "people"
, "bye-bye", "hello", "world!", "end" };
OuterLoop: for (int i = 0;i<6; i++) {
for (int j = 0; j < arrayOfString.length; j++) {
if (arrayOfString[j].equals("world!")) {
continue OuterLoop; // as goto from Csharp, or C/C++
}
System.out.println(arrayOfString[j]);
System.out.println(i);
if (i == 1) {
System.out.println("break");
break OuterLoop;
}
}
}
}
}
/*
nothing
0
Hello
0
people
0
bye-bye
0
hello
0
nothing
1
break
*/
If you using Context as parameter of function try this solution:
public class MyActivity extends Activity {
// bla bla bla .......
//error
myFc( getapplicationcontext());
// OK
myFc(MyActivity.this);
Copy file to another
Copy and compress file
File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File file = new File(path, "MyPicture.jpg");
// the Pictures directory exists?
path.mkdirs();
InputStream is = getResources().openRawResource(R.drawable.flower_blue);
OutputStream os = new FileOutputStream(file);
byte[] data = new byte[is.available()];
is.read(data);
os.write(data);
is.close();
os.close();
Copy and compress file
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
R.drawable.flower_blue);
try {
FileOutputStream out = new FileOutputStream("new_bitmap.jpg");
bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 90, out);
} catch (Exception e) {
e.printStackTrace();
Log.e("saveBitmap", e.getMessage());
}
Editace: 2013-11-10 20:31:20
Počet článků v kategorii: 396
Url:on-orientation-changed-view-button-textview-not-visible-android