Progressbar change background and fore color - Android sample
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" />
396LW NO topic_id
AD
Další témata ....(Topics)
Html.fromHtml(), setText(), textView.setText(Html.fromHtml(String htmlFormat)), Android example.
TextView mIdTextOk = (TextView)findViewById(R.id.idTextOk);
int _nOk = 57;
// number 57 will bold style
mIdTextOk.setText(Html.fromHtml( "OK: "+"<b>"+_nOk+"</b>"));
Try this code:
final String ERROR = "my error message....";
private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
// some code and method ..... see AsyncTask
@Override
protected String doInBackground(String... urls) {
URL urlL = null;
try {
urlL = new URL(url);//"//chmi.cz..../"
HttpURLConnection urlConnection = null;
try {
urlConnection = (HttpURLConnection) urlL.openConnection();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
response = readStream(in);
return response;
} catch (IOException e) {
//throw new RuntimeException(e);
} finally {
if(urlConnection != null)
urlConnection.disconnect();
return ERROR;
}
} catch (MalformedURLException e) {
e.printStackTrace();
return ERROR;
}
}
return response;
}
private String readStream(InputStream is) {
try {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
int i = is.read();
while(i != -1) {
bo.write(i);
i = is.read();
}
return bo.toString();
} catch (IOException e) {
return "";
}
}
import android.os.Build.VERSION;
//
int nSdkVersion = Integer.parseInt(Build.VERSION.SDK);
int nApiVersion = VERSION.SDK;
Platform Version | API Level |
---|---|
Android 4.0 | 14 |
Android 3.2 | 13 |
Android 3.1.x | 12 |
Android 3.0.x | 11 |
Android 2.3.4 | 10 |
Android 2.3.3 | 10 |
Android 2.3.2 | 9 |
Android 2.3.1 | 9 |
Android 2.3 | 9 |
Android 2.2.x | 8 |
Android 2.1.x | 7 |
Android 2.0.1 | 6 |
Android 2.0 | 5 |
Android 1.6 | 4 |
Android 1.5 | 3 |
Android 1.1 | 2 |
Android 1.0 | 1 |
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>
Put your sglite database to Android Eclipse project folder named Assets.
On device will copy database file to application folder as this example:
On device will copy database file to application folder as this example:
public void createDatabase(Context myContext) throws IOException {
String sPackName = myContext.getPackageName();
InputStream assetsDB = myContext.getAssets().open("myDatabase");
OutputStream dbOut = new FileOutputStream("/data/data/"+sPackName+"/database");
byte[] buffer = new byte[1024];
int length;
while ((length = assetsDB.read(buffer))>0){
dbOut.write(buffer, 0, length);
}
dbOut.flush();
dbOut.close();
assetsDB.close();
}
Editace: 2011-10-25 16:23:39
Počet článků v kategorii: 396
Url:progressbar-background-and-fore-color-android-sample