ali*_*tha 15 testing android dialog
我试图获取消息,以下代码行有效:
TextView dialogMessage = (TextView)dialogObject.findViewById(android.R.id.message);
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用以下行获取标题时它返回 null
TextView dialogTitle = (TextView)dialogObject.findViewById(android.R.id.tittle);
Run Code Online (Sandbox Code Playgroud)
Bla*_*elt 27
我检查了代码AlertDialog.在内部,他们R.id.alertTitle用来初始化AlertDialog标题TextView.您可以使用getIdentifier它来检索它:
int titleId = getResources().getIdentifier( "alertTitle", "id", "android" );
if (titleId > 0) {
TextView dialogTitle = (TextView) dialogObject.findViewById(titleId);
if (dialogTitle != null) {
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7721 次 |
| 最近记录: |