https://imgur.com/gallery/xntpREw
Has anyone faced this issue or am I doing anything wrong
UPDATE: I tested the same app on android 8 and 9 version and it doesn't give this glitch.So, this might be specific to android version 10
EDIT:
This is the dialog fragment class where an alert dialog is called on itemview click-
public class ItemListDialogFragment extends BottomSheetDialogFragment
{
private static final String ARG_ITEM_COUNT = "item_count";
public static ItemListDialogFragment newInstance(int itemCount)
{
final ItemListDialogFragment fragment =
new ItemListDialogFragment();
final Bundle args = new Bundle();
args.putInt(ARG_ITEM_COUNT, itemCount);
fragment.setArguments(args);
return fragment;
}
@Nullable
@Override
public View onCreateView(
LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState)
{
return inflater.inflate(
R.layout.
fragment_item_list_dialog_list_dialog,
container,
false );
}
@Override
public void onViewCreated(
@NonNull View view,
@Nullable Bundle savedInstanceState )
{
final RecyclerView recyclerView =
(RecyclerView) view;
recyclerView.setLayoutManager(
new LinearLayoutManager( getContext() ) );
recyclerView.setAdapter(
new ItemAdapter( getArguments().getInt( ARG_ITEM_COUNT ) ) );
recyclerView.setOnClickListener(
new View.OnClickListener()
{
@Override
public void onClick(View view)
{
alert();
}
} );
}
private class ViewHolder extends RecyclerView.ViewHolder
{
final TextView text;
ViewHolder(
LayoutInflater inflater,
ViewGroup parent )
{
// TODO: Customize the item layout
super(
inflater.inflate(
R.layout.
fragment_item_list_dialog_list_dialog_item,
parent,
false ) );
text = itemView.findViewById(R.id.text);
itemView.setOnClickListener(
new View.OnClickListener()
{
@Override
public void onClick( View view )
{
alert();
}
} );
}
}
private class ItemAdapter extends RecyclerView.Adapter<ViewHolder>
{
private final int mItemCount;
ItemAdapter( int itemCount )
{
mItemCount = itemCount;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(
@NonNull ViewGroup parent,
int viewType)
{
return new ViewHolder(
LayoutInflater.from( parent.getContext( ) ),
parent );
}
@Override
public void onBindViewHolder( ViewHolder holder, int position )
{
holder.text.setText( String.valueOf( position ) );
}
@Override
public int getItemCount()
{
return mItemCount;
}
}
private void alert()
{
AlertDialog.Builder builder =
new AlertDialog.Builder( getActivity() );
builder.setTitle( "Alert dialog" );
builder.setMessage( "This is a alert dialog" );
builder.setPositiveButton(
"ok",
new DialogInterface.OnClickListener()
{
@Override
public void onClick( DialogInterface dialogInterface, int i )
{
}
} );
builder.setNegativeButton(
"close",
new DialogInterface.OnClickListener()
{
@Override
public void onClick( DialogInterface dialogInterface, int i )
{
}
} );
builder.show();
}
and this is how the bottom sheet is called -
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_main );
ItemListDialogFragment.
newInstance(10).
show( getSupportFragmentManager(), "df" );
}
}