head

2013年9月16日月曜日

Android ProgressBar Custom(カスタム版)の作成 2013-09-16

さて、通常のProgressDialogを
使用してましたが、違う部品を作成してみました。

[1] 背景や、サイズを変更できるので。使い道はあるかも。

[2] AsyncTask内などで、使えればよいな。と思ってます。
 サンプルはハンドラで止めてます。デモの為。

[3] こんな感じです。



ソースはこちら。どうぞ
https://github.com/kuc-arc-f/TestProg2


[4] 説明など

====== Laytout-XML (prog.xml)
<com.example.testprog.CustumProgress
        android:id="@+id/progress1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
</com.example.testprog.CustumProgress>
======

コンストラクタで。
プログレス、プログレス下の文字セットします。

======SRC一部分
    public CustumProgress(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.setOrientation(VERTICAL);
        setBackgroundColor(Color.argb(128, 0, 0, 0));
        this.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);
        mContext = context;
       
        init_progress(context);
    }
   
    void init_progress(Context context){
    mProgress= new ProgressBar(context);
    int i_w   = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,  WIDTH_PROG, this.getResources().getDisplayMetrics());
    int i_h   = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,  HEIGHT_PROG, this.getResources().getDisplayMetrics());
    int i_ht  = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,  HEIGHT_TXT, this.getResources().getDisplayMetrics());
   
        LinearLayout.LayoutParams llp =  new LinearLayout.LayoutParams(i_w, i_h);
        mProgress.setLayoutParams(llp);
        mProgress.setBackgroundColor(Color.BLACK );
        this.addView(mProgress);
       
        mTextView= new TextView(context);
        LinearLayout.LayoutParams llt =  new LinearLayout.LayoutParams(i_w, i_ht);
        mTextView.setLayoutParams(llt);
        mTextView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
        mTextView.setBackgroundColor(Color.BLACK );
        mTextView.setTextColor(Color.WHITE);
        addView(mTextView);
       
        setVisibility(View.INVISIBLE);
    }
====

呼び出し、アクティビティ側
LayoutInflaterで、XML指定し、
CustumProgressを読み込みます。その後Viewを追加。

====
void progress_init( )
{
View view = this.getLayoutInflater().inflate(R.layout.prog, null);
mCProgress= (CustumProgress)view.findViewById(R.id.progress1);
mCProgress.set_titie("Loadging..");

addContentView(view, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT ));
}
===
*) どうそ
https://github.com/kuc-arc-f/TestProg2

それではまた。



google colaboratory お試し編 、GPUも使える機械学習の環境構築

前回続き、機械学習の関連となります。 開発環境まわりの内容となり。先人様の情報を元に調査しました。 google colab(google colaboratory) を試してみました。機械学習系の いくつかのライブラリがインストール済みで、 クラウド上で、ある程度機械学...

AD-parts

Shop
Bluetooth搭載
ベース基板

Social