There is a task to make a SeekBar
for MediaPlayer
. SeekBar
is in Dialog
, which is based on layout.xml
, i.e. custom
. I tried through LayoutInflater
, but the impression is that the elements now see, but nothing can be done with them.
I give the code. In protected void onCreate(Bundle savedInstanceState)
I have a ListView
and is set to it list1.setOnItemClickListener(new AdapterView.OnItemClickListener()
. On click I create a dialog
:
final Dialog dialog = new Dialog(music_act.this); dialog.setContentView(R.layout.playdialog); dialog.setTitle("Сейчас играет"); TextView dtitle = (TextView) dialog.findViewById(R.id.textView); dtitle.setText(((TextView) itemClicked).getText()); dialog.show();
In the dialogue by clicking on the button I do
public void onClickP(View v) { LayoutInflater factory = getLayoutInflater(); View dial = factory.inflate(R.layout.playdialog, null); buttonP = (Button)dial.findViewById(R.id.button); if (mediaPl.isPlaying() == true) { mediaPl.pause(); buttonP.setBackgroundResource(R.drawable.ic_play_arrow_black_48dp); } else if (mediaPl.isPlaying() == false) { mediaPl.start(); buttonP.setBackgroundResource(R.drawable.ic_pause_black_48dp); } }
But! The background of the button does not change, and nothing happens at all except for launching and pausing the player (the control of other elements has been deleted; it was done in the same way). Any more and records in broad gulls.
Question: how to properly manage elements in Dialog
, if it is based on layout.xml
. SeekBar
possible: how to SeekBar
to the MediaPlayer
in such a case. Thank you for your time.