Я должен взять текст из AlertDialog.
Для AlertDialog я использую специальную раскладку: custom_alertdialog
Вместо этого для всего проекта используйте: another layout
Я пытался так:
View layout = getLayoutInflater().Inflate(R.layout.custom_alertdialog,null);
Или так:
View layout = View.inflate(SimpleVideoStream.this, R.layout.custom_alertdialog, null);
Но текст не берется ни в одном случае.
Как я могу это сделать?
AlertDialog.Builder builder = new AlertDialog.Builder(SimpleVideoStream.this);
builder.setTitle("Add Subtitle");
builder.setCancelable(true);
builder.setPositiveButton(
"Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
View inflatedView = getLayoutInflater().inflate(R.layout.custom_alertdialog, null);
final View layout = View.inflate(SimpleVideoStream.this, R.layout.custom_alertdialog, null);
EditText url_ele = (EditText) layout.findViewById(R.id.url);
String sub = url_ele.getText().toString();
Log.v("Ok:","/"+sub);
if (!sub.equals("")) {
showSub = !showSub;
Format textFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP,
null, Format.NO_VALUE, Format.NO_VALUE, "en", null, Format.OFFSET_SAMPLE_RELATIVE);
MediaSource textMediaSource = new SingleSampleMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(sub), textFormat, C.TIME_UNSET);
videoSource = new MergingMediaSource(videoSource, textMediaSource);
player.prepare(videoSource, false, false);
}
dialog.cancel();
}
});
builder.setNegativeButton(
"Close",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
LayoutInflater inflater = getLayoutInflater();
View dialoglayout = inflater.inflate(R.layout.custom_alertdialog, null);
alert.setView(dialoglayout);
alert.show();