1.先自定義乙個彈出框的樣式
2.自己實現customdialog類,繼承自dialog,實現裡面方法,在裡面載入自定義樣式的彈出框;
3.使用時,與使用dialog一樣
<?xml version="1.0" encoding="utf-8"?>
package com.jiayinlending.widget.dialog;
import android.content.context;
import android.content.dialoginte***ce;
import android.view.layoutinflater;
import android.view.view;
import android.widget.button;
import android.widget.linearlayout;
import android.widget.textview;
import android.view.viewgroup.layoutparams;
import com.jiayinlending.r;
/** * created by $ on 2017/5/18.
*/public class customdialog extends dialog
public customdialog(context context, int theme)
public static class builder
public builder setmessage(string message)
/*** set the dialog message from resource
** @param
* @return
*/public builder setmessage(int message)
/*** set the dialog title from resource
** @param title
* @return
*/public builder settitle(int title)
/*** set the dialog title from string
** @param title
* @return
*/public builder settitle(string title)
public builder setcontentview(view v)
/*** set the positive button resource and it's listener
** @param positivebuttontext
* @return
*/public builder setpositivebutton(int positivebuttontext,
dialoginte***ce.onclicklistener listener)
public builder setpositivebutton(string positivebuttontext,
dialoginte***ce.onclicklistener listener)
public builder setnegativebutton(int negativebuttontext,
dialoginte***ce.onclicklistener listener)
public builder setnegativebutton(string negativebuttontext,
dialoginte***ce.onclicklistener listener)
public customdialog create()
});}
} else
// set the cancel button
if (negativebuttontext != null)
});}
} else
// set the content message
if (message != null) else if (contentview != null)
dialog.setcontentview(layout);
return dialog;}}
}
case r.id.iv_tips:
//建立dialog
customdialog.builder builder = new customdialog.builder(getcontext());
builder.setmessage(getresources().getstring(r.string.service_number_tips));
builder.settitle("");
builder.setpositivebutton("我知道了", new dialoginte***ce.onclicklistener()
});builder.create().show();
break;
android自定義彈出框樣式實現
android自定義彈出框樣式實現 做專案時,感覺android自帶的彈出框樣式比較醜,很多應用都是自己做的彈出框,這裡也試著自己做了乙個。廢話不說先上 1.先自定義乙個彈出框的樣式 2.自己實現customdialog類,繼承自dialog,實現裡面方法,在裡面載入自定義樣式的彈出框 3.使用時,...
Android自定義彈出框AlertDialog
今天有空把自定義彈出框研究了一下,一直在用,都沒有仔細的看 今兒mark一下。先上個圖,做出來的效果 step 1 先自定義乙個顯示圖,我寫的xml檔案如下 這裡為了讓現實框變成圓角的,在linearlayout空間上加了乙個background,檔名是window bg,具體的圓角實現如下 這樣就...
Android自定義輸入框樣式
資料來自 菜鳥教程 自行編寫乙個shapedrawable的資源檔案!然後textview將blackgroung 設定為這個drawable資源即可!shapedrawable資源檔案的幾個節點以及屬性 需要改變游標的顏色 1 自定義bg cursor的drawable下xml檔案 2 在edit...