彈出展示詳情界面

先上圖


效果圖

上代碼
ExpertDialog.java

public class ExpertDialog extends Dialog {

    private Callback callback;
    private int position;
    private Context context;
    private RecyclerView dialogExpertRv;
    private CircleImageView dialogExpertIcon;
    private TextView dialogExpertName;
    private TextView dialogExpertTechnology;
    private TextView dialogExpertInquiry;

    private SingleAdapter<ExpertDialogEntity> adapter;

    private List<ExpertDialogEntity> list;

    /**
     * Find the Views in the layout<br />
     * <br />
     * Auto-created on 2018-01-04 10:44:15 by Android Layout Finder
     * (http://www.buzzingandroid.com/tools/android-layout-finder)
     */
    private void findViews(View mView) {
        dialogExpertRv = (RecyclerView) mView.findViewById(R.id.dialog_expert_rv);
        dialogExpertIcon = (CircleImageView) mView.findViewById(R.id.dialog_expert_icon);
        dialogExpertName = (TextView) mView.findViewById(R.id.dialog_expert_name);
        dialogExpertTechnology = (TextView) mView.findViewById(R.id.dialog_expert_technology);
        dialogExpertInquiry = (TextView) mView.findViewById(R.id.dialog_expert_inquiry);
    }


    public ExpertDialog(@NonNull Context context, int position, Callback callback) {
        super(context, R.style.CustomDialogWifi);
        this.context = context;
        this.callback = callback;
        this.position = position;
        setDialog();
    }

    private void setDialog() {
        View mView = LayoutInflater.from(getContext())
                .inflate(R.layout.dialog_epert_show_layout, null);
        findViews(mView);
        dialogExpertInquiry.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callback.callback(position);
                dismiss();
            }
        });
        //點(diǎn)擊外部可以消失
        this.setCanceledOnTouchOutside(true);
        super.setContentView(mView);
    }

    /**
     * 頭像
     *
     * @param iconPath
     * @return
     */
    public ExpertDialog setIcon(String iconPath) {
        GlideImageLoader.init().displayImage(context, iconPath, dialogExpertIcon);
        return this;
    }

    /**
     * 姓名和職稱(chēng)
     *
     * @param expertName
     * @param expertTech
     * @return
     */
    public ExpertDialog setTitle(String expertName, String expertTech) {
        if (!TextUtils.isEmpty(expertName) && TextUtils.isEmpty(expertTech)) {
            dialogExpertName.setText(expertName);
            dialogExpertTechnology.setText(expertTech);
        }
        return this;
    }

    /**
     * 內(nèi)容
     *
     * @param list
     * @return
     */
    public ExpertDialog setContent(List<ExpertDialogEntity> list) {

        adapter = new SingleAdapter<ExpertDialogEntity>(context,
                R.layout.adapter_expert_list_item_layout,
                list) {
            @Override
            public void convert(ViewHolder holder, ExpertDialogEntity expertDialogEntity, int position) {

                holder.setText(R.id.tv_expert_item_title, expertDialogEntity.getItemTitle());
                holder.setText(R.id.tv_expert_item_content, expertDialogEntity.getItemContent());
                GlideImageLoader.init().displayImage(context,
                        expertDialogEntity.getItemIcon(), (ImageView) holder.getView(iv_expert_item_icon));

            }
        };
        dialogExpertRv.setLayoutManager(new LinearLayoutManager(context));
        dialogExpertRv.setAdapter(adapter);
        return this;
    }

    /**
     * 對(duì)話框消失
     */
    public void dimiss() {
        ExpertDialog.this.cancel();
    }

    /**
     * 點(diǎn)擊后禁止再次點(diǎn)擊
     */
    public void isEnabled() {
        dialogExpertInquiry.setClickable(false);
        dialogExpertInquiry.setEnabled(false);
    }
}

布局文件,dialog_epert_show_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/margin_space_20"
        android:layout_marginRight="@dimen/margin_space_20"
        android:background="@color/transparent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp"
            android:background="@drawable/update_manager_bg"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="50dp"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/dialog_expert_name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin_space_10"
                    android:gravity="center"
                    android:text="專(zhuān)家王"
                    android:textColor="@color/black2"
                    android:textSize="18sp" />

                <TextView
                    android:id="@+id/dialog_expert_technology"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin_space_5"
                    android:gravity="center"
                    android:text="農(nóng)技員"
                    android:textColor="@color/common_green_color"
                    android:textSize="14sp" />

            </LinearLayout>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/dialog_expert_rv"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:overScrollMode="never"
                android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>

            <TextView
                android:id="@+id/dialog_expert_inquiry"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/margin_space_20"
                android:layout_marginLeft="@dimen/margin_space_20"
                android:layout_marginRight="@dimen/margin_space_20"
                android:layout_marginTop="@dimen/margin_space_10"
                android:background="@drawable/tv_dialog_expert_inquiry_bg"
                android:gravity="center"
                android:paddingTop="@dimen/margin_space_10"
                android:paddingBottom="@dimen/margin_space_10"
                android:text="立即詢(xún)問(wèn)"
                android:textColor="@color/white"
                android:textSize="16sp" />

        </LinearLayout>

        <com.gstb.agriculture.utils.CircleImageView
            android:id="@+id/dialog_expert_icon"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_gravity="center|top"
            android:scaleType="fitXY"
            android:src="@drawable/user_icon"></com.gstb.agriculture.utils.CircleImageView>


    </FrameLayout>


</LinearLayout>

在style.xml里面配置

 <style name="CustomDialogWifi" parent="@android:style/Theme.Translucent">
        <item name="android:windowFrame">@null</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowIsTranslucent">false</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:backgroundDimEnabled">true</item>
    </style>

SingleAdapter的使用可以參考我的這個(gè)列子https://github.com/liuxinggen/adapter

使用方法

      ExpertDialog dialog = new ExpertDialog(activity, position, new Callback() {
            @Override
            public void callback(int position) {
                Toast.makeText(activity, "點(diǎn)擊立即咨詢(xún)" + position, Toast.LENGTH_SHORT).show();
                intent = new Intent(activity, ExpertDetailsActivity.class);
                intent.putExtra("title", "詢(xún)問(wèn)專(zhuān)家詳情");
                startActivity(intent);
            }
        });
        dialog.setIcon("http://p2.so.qhimgs1.com/t01f3cd841f22f826d2.jpg");
        dialog.setTitle("專(zhuān)家黃", "高級(jí)工程師");
        dialog.setContent(list);
        dialog.show();
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末威蕉,一起剝皮案震驚了整個(gè)濱河市刁俭,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌韧涨,老刑警劉巖牍戚,帶你破解...
    沈念sama閱讀 218,546評(píng)論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異氓奈,居然都是意外死亡翘魄,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,224評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門(mén)舀奶,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)暑竟,“玉大人,你說(shuō)我怎么就攤上這事育勺〉纾” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 164,911評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵涧至,是天一觀的道長(zhǎng)腹躁。 經(jīng)常有香客問(wèn)我,道長(zhǎng)南蓬,這世上最難降的妖魔是什么纺非? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,737評(píng)論 1 294
  • 正文 為了忘掉前任,我火速辦了婚禮赘方,結(jié)果婚禮上烧颖,老公的妹妹穿的比我還像新娘。我一直安慰自己窄陡,他們只是感情好炕淮,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,753評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著跳夭,像睡著了一般涂圆。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上币叹,一...
    開(kāi)封第一講書(shū)人閱讀 51,598評(píng)論 1 305
  • 那天润歉,我揣著相機(jī)與錄音,去河邊找鬼套硼。 笑死卡辰,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的邪意。 我是一名探鬼主播九妈,決...
    沈念sama閱讀 40,338評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼雾鬼!你這毒婦竟也來(lái)了萌朱?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 39,249評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤策菜,失蹤者是張志新(化名)和其女友劉穎晶疼,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體又憨,經(jīng)...
    沈念sama閱讀 45,696評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡翠霍,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,888評(píng)論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了蠢莺。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片寒匙。...
    茶點(diǎn)故事閱讀 40,013評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖躏将,靈堂內(nèi)的尸體忽然破棺而出锄弱,到底是詐尸還是另有隱情,我是刑警寧澤祸憋,帶...
    沈念sama閱讀 35,731評(píng)論 5 346
  • 正文 年R本政府宣布会宪,位于F島的核電站,受9級(jí)特大地震影響蚯窥,放射性物質(zhì)發(fā)生泄漏掸鹅。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,348評(píng)論 3 330
  • 文/蒙蒙 一拦赠、第九天 我趴在偏房一處隱蔽的房頂上張望巍沙。 院中可真熱鬧,春花似錦矛紫、人聲如沸赎瞎。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,929評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)务甥。三九已至,卻和暖如春喳篇,著一層夾襖步出監(jiān)牢的瞬間敞临,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,048評(píng)論 1 270
  • 我被黑心中介騙來(lái)泰國(guó)打工麸澜, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留挺尿,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,203評(píng)論 3 370
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像编矾,于是被迫代替她去往敵國(guó)和親熟史。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,960評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 172,149評(píng)論 25 707
  • afinalAfinal是一個(gè)android的ioc窄俏,orm框架 https://github.com/yangf...
    passiontim閱讀 15,434評(píng)論 2 45
  • 項(xiàng)目概況:龍崗區(qū)河道管養(yǎng)三標(biāo)段管養(yǎng)的河道分布于園山蹂匹、橫崗2個(gè)街道,共計(jì)17條河流凹蜈,總長(zhǎng)度46.1公里限寞,分屬于龍崗河...
    H__Zzzzzz閱讀 336評(píng)論 0 0
  • 前陣子在朋友圈曬了PMP考試通過(guò)的證書(shū),一些朋友表示疑問(wèn)仰坦,不知道是干啥子的履植,還都是英文。 百度一下悄晃,全都有玫霎,簡(jiǎn)單來(lái)...
    Jessica00閱讀 1,605評(píng)論 0 0
  • 昨晚做了個(gè)夢(mèng) 夢(mèng)里你撐著淡藍(lán)色的油紙傘 走在寂寞悠長(zhǎng)墨綠色的小巷 巷子深處的漆黑 是我的憂慮 我祈求你不要走進(jìn)去 ...
    玉人初上閱讀 345評(píng)論 1 6