Title共通写法
用:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background_shadow">
<jp.co.gunmabank.view.AccountAppTitleLayout
android:id="@+id/title_talk"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="10dip"></jp.co.gunmabank.view.AccountAppTitleLayout>
</LinearLayout>
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"
android:background="@color/color_account_title_bg"
android:id="@+id/open_set_title_background"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/open_account_title_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/back_btn"
android:gravity="center" />
<TextView
android:id="@+id/open_account_title_name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:textSize="15sp" />
<Button
android:id="@+id/testDb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DBtest" />
<TextView
android:id="@+id/open_account_close"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginRight="5dp"
android:gravity="center"
android:text="中断する"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>
类:
package jp.co.view
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
//アプリのタイトル
class AccountAppTitleLayout(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) {
init {
//充填画面
LayoutInflater.from(context).inflate(R.layout.open_account_title_layout, this)
//活動
val activity = (getContext() as Activity)
//backキー
val titleBack = findViewById(R.id.open_account_title_back) as ImageView
titleBack.setOnClickListener {
Common.closeKeyboard(activity, titleBack)
activity.finish()
}
//中断する
val openAccountClose = findViewById(R.id.open_account_close) as TextView
openAccountClose.setOnClickListener {
//ダイアログ
val confirmDialog = CloseConfirmDialog(activity, "お申込みの手続きを中断してポータル画面に戻りますか?", "", "はい", "いいえ", true)
//ダイアログ
confirmDialog.setClicklistener(object : CloseConfirmDialog.ClickListenerInterface {
//はい
override fun doConfirm() {
//MainTab画面遷移
var intent = Intent(activity, MainTabActivity::class.java);
activity.startActivity(intent)
ActivityCollector.accountFinishAll()
confirmDialog.dismiss()
}
//いいえ
override fun doCancel() {
confirmDialog.dismiss()
}
})
confirmDialog.show()
}
}
}