I´ve stumbled across the following problem coding my app:
Whenever the statement Txtname.setText(name)
is not suppressed, the app keeps crashing. Even when I hardcode string in, there it crashes. Via the toast I was able to see that the string name is passed correctly.
//OnListpress
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long l) {
Log.d(TAG, "onItemClick: name:" + thelist.get(i));
String name = thelist.get(i);
Showpopup(name);
}
//PopUP
private void Showpopup(final String name) {
myDialog = new Dialog(getActivity());
myDialog.setContentView(R.layout.popup_list);
myDialog.show();
EditText Txtname = getActivity().findViewById(R.id.TxtNAME);
Txtname.setText(name);
Toast.makeText(getActivity(),name,Toast.LENGTH_LONG).show();
}
});
I found a few topics regarding this problem, but they always used Fragments as basis for the edittext. Mine is a dialog and the presented ways don't seem to work for me. I hope somebody knows the fix, thanks in advance!