Date getDate is deprecated Java Android
Date getDate is deprecated Java Android example code:
long dayInMili = 100000000;
GregorianCalendar calToDay = new GregorianCalendar();
int nD = calToDay.get((Calendar.MILLISECOND)); // +dayInMili;
System.out.println(nD);
long lTime = calToDay.getTimeInMillis();
System.out.println(lTime);
Date dtA = new Date(lTime); // today
///@SuppressWarnings("deprecation")
int nD1 = dtA.getDate(); // DEPRECATED Day Of Month 1 - 31
System.out.println(nD1+" nD1");
GregorianCalendar cal = new GregorianCalendar();
int nD2 = calToDay.get(Calendar.DATE); // Day Of Month
System.out.println(nD2+" nD2");
cal.setTimeInMillis(lTime+dayInMili);// setTime(dtA);
int nD3 = cal.get(Calendar.DATE); // Day Of Month + 1 day
System.out.println(nD3+" nD3");
396LW NO topic_id
AD
Další témata ....(Topics)
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);
}
}
}
Spinner in Android application is equivalent of ComboBox in WinApi.
Spinner get selected item to string example.
Spinner get selected item position to int example.
Main activity class MainComboBox.java
File MyOnItemSelectedListener.java
strings.xml
main.xml
Spinner get selected item to string example.
Spinner get selected item position to int example.
Main activity class MainComboBox.java
public class MainComboBox extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.countries_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
Button myButton =(Button)findViewById(R.id.button1);
myButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Spinner sp = (Spinner)findViewById(R.id.spinner);
String spinnerString = null;
spinnerString = sp.getSelectedItem().toString();
int nPos = sp.getSelectedItemPosition();
Toast.makeText(getApplicationContext(), "getSelectedItem=" + spinnerString,
Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "getSelectedItemPosition=" + nPos,
Toast.LENGTH_LONG).show();
}
});
}
}
File MyOnItemSelectedListener.java
public class MyOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
Toast.makeText(parent.getContext(), "Item is " +
parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();
}
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}
strings.xml
<resources>
<string name="hello">Hello World, MainComboBox!</string>
<string name="app_name">ComboBox</string>
<string name="prompt">Choose a country</string>
<string-array name="countries_array">
<item>China</item>
<item>India</item>
<item>USA</item>
<item>Indonesia</item>
<item>Brazil</item>
<item>Pakistan</item>
<item>Nigeria</item>
<item>Bangladesh</item>
<item>Russia</item>
</string-array>
</resources>
main.xml
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="@string/prompt"
/>
<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/prompt"
/>
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
Adding TableRow with a View TextView (EditText Button) programmically dynamically to TableLayout Android sample basic example.
MainClass.java
main.xml
MainClass.java
public class MainClass extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TableLayout tl = (TableLayout)findViewById(R.id.tableLayout1);
TableRow row = new TableRow(this);
TextView tv = new TextView(this);
tv.setText("This is text");
tl.addView(row);
row.addView(tv);
}
}
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_width="fill_parent"
android:id="@+id/tableLayout1" android:layout_height="wrap_content">
</TableLayout>
</LinearLayout>
Try this solution:
String DATA = "Html text....bla bla bla. Hellou world! čšřžěéá";
String HEADERHTML =
"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">"
+"<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8">"
+"</head> <body>";
String FOOTERHTML = "</body></html>";
WebView mWebView.loadData(HEADERHTML+DATA+FOOTERHTML,"text/html; charset=UTF-8",null);
choreographer skipped frames
Create filter with TAG regex to disable Choreographer messages, see code and picture below:
Create filter with TAG regex to disable Choreographer messages, see code and picture below:
^((?!Choreographer).)*$
Editace: 2012-12-07 14:42:23
Počet článků v kategorii: 396
Url:date-getdate-is-deprecated-java-android