Date Calendar Java Android Example
Calendar cal = new GregorianCalendar(), int year = cal.get(Calendar.YEAR),
ERA, MONTH, DAY_OF_MONTH, DAY_OF_WEEK, Android example code.
ERA, MONTH, DAY_OF_MONTH, DAY_OF_WEEK, Android example code.
public class MainActivity extends Activity {
TextView txtV;
Context cntx;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txtV = (TextView)findViewById(R.id.idLabel);
cntx = this;
Calendar cal = new GregorianCalendar();
int era = cal.get(Calendar.ERA); // 0 B.C. before Christ, 1 Anno Domini
txtV.setText(txtV.getText() +"
" + era);
int year = cal.get(Calendar.YEAR); // 2011
txtV.setText(txtV.getText() +"
" + year);
int month = cal.get(Calendar.MONTH); // 0 is Januar
txtV.setText(txtV.getText() +"
" + month);
int day = cal.get(Calendar.DAY_OF_MONTH); // 1 to 31
txtV.setText(txtV.getText() +"
" + day);
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); // 1=Sunday, 2=Monday ...
txtV.setText(txtV.getText() +"
" + dayOfWeek);
}
}
396LW NO topic_id
AD
Další témata ....(Topics)
MainActivity.java
res/layout/main.xml
res/drawable/my_progress.xml
ProgressBar mProgressBarScore;
// onCreate
mProgressBarScore = (ProgressBar)findViewById(R.id.progressBarScore);
Resources res = getResources();
mProgressBarScore.setProgressDrawable(res.getDrawable( R.drawable.my_progress));
res/layout/main.xml
<ProgressBar
android:id="@+id/progressBarScore"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:max="100"/>
res/drawable/my_progress.xml
-
android:startColor="#FF001A"
android:centerColor="#ff5a5d5a"
android:centerY="0.75"
android:endColor="#FF001A"
android:angle="270"
/>
-
android:startColor="#80ffd300"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:angle="270"
/>
android:id="@android:id/progress"
>
android:radius="10dip" />
android:startColor="#00ff00"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#339900"
android:angle="270" />
In your project AndroidManifest.xml you can set permission of Android application example source code.
For example if you want allow your application connection to INTERNET you have to permit this in AndroidManifest.xml.
WebViev show error: Website Not Available you have to permit INTERNET
For example if you want allow your application connection to INTERNET you have to permit this in AndroidManifest.xml.
WebViev show error: Website Not Available you have to permit INTERNET
<uses-permission
android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.GET_ACCOUNTS" />
<uses-permission
android:name="android.permission.USE_CREDENTIALS" />
<uses-permission
android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission
android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission
android:name="android.permission.WRITE_SETTINGS" />
<uses-permission
android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission
android:name="android.permission.READ_CONTACTS" />
<uses-permission
android:name="android.permission.WRITE_CONTACTS" />
<uses-permission
android:name="android.permission.READ_SYNC_STATS" />
<uses-permission
android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission
android:name="android.permission.WRITE_SYNC_SETTINGS" />
Try convert WAV file to MP3 format for example by Audacity sound editor and replay:
//audacity.sourceforge.net/help/faq_i18n?s=install&i=lame-mp3
//audacity.sourceforge.net/help/faq_i18n?s=install&i=lame-mp3
MediaPlayer mp = MediaPlayer.create(getApplicationContext(), R.raw.mymp3file);
mp.setLooping(true);
mp.start();
String s = "Some text for appending
";
TextView mTitle = (TextView) findViewById(R.id.title_text);
mTitle.setText(R.string.app_name); // insert text from strings.xml
mTitle.append(s); // append string like a variable value
mTitle.append("My string will appended
"); // append string
You can insert this source code into onCreate in your activity file
Sqlite3 create database and table with load.bat file and fill data to table example.
- Create folder for your project: my_sqlite_project
- Open folder and create file load.bat and paste to load.bat this text and save to project folder:
sqlite3 my_database.s3db < load_text.sql
pause
- Create load_text.sql file and paste this text and save to project folder:
CREATE TABLE [android_metadata] (
[locale] TEXT
);
CREATE TABLE [my_table] (
[_id] int NULL,
[word] VARCHAR(255) NULL,
[description] VARCHAR(255) NULL
.separator ";"
.import text_file.txt my_table
- Create text_file.txt and paste this text and save it as UTF-8:
1;word1;my first word
2;word2; my second word - Download sqlite3.exe and put to project folder.
- Run BAT file load.bat and read text instruction from console
- If database created you can open and edit this with sqlite database explorer
- Copy database to Asses Android project folder
- If you want using this database in Android application on device, you have to copy this database to folder on device /data/data/com.MyPackage/databases/
Editace: 2011-09-29 13:32:10
Počet článků v kategorii: 396
Url:date-calendar-java-android-example