alertDialog with confusing layout in fragment

1

I can not change the layout of a alertDialog() that inherited a layout I do not know from where. I've already tried to set a customAlertDialogLayout also unsuccessful. I already tried to change the context and nothing seems to work.

SedeFragment.java

package br.gov.rj.pmerj.policialoficialsv.fragments;

/**
 * A simple {@link Fragment} subclass.
 *
 */
public class SedeFragment extends Fragment implements RecyclerViewOnClickListenerHack {
  private RecyclerView mRecyclerView;
  private ImageButton mImageButton;
  private List < Sede > mList;
  //public LegislacaoDao legislacaoDao;
  Fragment fragment;
  public Bundle savedInstanceState;
  public SedeDao sededaoDaoselecionado;
  int mpId = 0;
  String exStoragePath = Environment.getExternalStorageDirectory().getAbsolutePath();
  String path = (exStoragePath + "/media/alarms/");
  public Sede sede;
  public SedeDao sedeDao;


  public SedeFragment() {
    // Required empty public constructor
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
    View view;

    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_sede, container, false);

    mRecyclerView = (RecyclerView) view.findViewById(R.id.rv_list);
    mImageButton = (ImageButton) view.findViewById(R.id.imgrota);
    mRecyclerView.setHasFixedSize(true);
    GridLayoutManager llm = new GridLayoutManager(getActivity(), 1, GridLayoutManager.VERTICAL, false);
    mRecyclerView.setLayoutManager(llm);
    mRecyclerView.addOnItemTouchListener(new RecyclerViewTouchListener(getActivity(), mRecyclerView, this));
    // mRecyclerView.addOnItemTouchListener(new RecyclerViewTouchListener( getActivity(), mRecyclerView, this ));
    //GridLayoutManager llm = new GridLayoutManager(getActivity(), 1, GridLayoutManager.VERTICAL, false);
    mRecyclerView.setLayoutManager(llm);
    sedeDao = new SedeDao((MainActivity) getActivity());
    //LegislacaoDao legislacaoDao = new LegislacaoDao((MainActivity) getActivity());
    //mList = (ArrayList<Legislacao>) legislacaoDao.listar();
    mList = (ArrayList < Sede > ) sedeDao.listar();

    // SedeAdapter adapter = new SedeAdapter(getActivity().getApplicationContext(), mList);
    SedeAdapter adapter = new SedeAdapter(getActivity(), mList);

    mRecyclerView.setAdapter(adapter);

    return view;

  }
  @Override
  public void onLongPressClickListener(View view, int position) {

    // acao2(getActivity(),mList.get(position));
    //  return false;
    //saveas();
    //Toast.makeText(getActivity(), "onLongPressClickListener(): "+position, Toast.LENGTH_SHORT).show();
    // Toast.makeText(getActivity(), "onLongPressClickListener(): "+passaro.getCantoAudio(), Toast.LENGTH_SHORT).show();
    /*CarAdapter adapter = (CarAdapter) mRecyclerView.getAdapter();
    adapter.removeListItem(position);*/
  }
  @Override
  public void onClickListener(View view, int position) {
    switch (view.getId()) {
      case R.id.imgrota:
        sededaoDaoselecionado = new SedeDao(getContext());
        Bundle bundle = new Bundle();
        bundle.putInt("iditem", mList.get(position).getId());
        String s;
        s = mList.get(position).getEndereco();
        Toast.makeText(getContext(), mList.get(position).getOpm() + " - " + mList.get(position).getEndereco() + " - " + mList.get(position).getBairro() + " - " + mList.get(position).getMunicipio(), Toast.LENGTH_SHORT).show();

        break;
    }


    //   sededaoDaoselecionado = new SedeDao(getContext());


    //Toast.makeText(getContext(), "teste"+itemdaoDaoselecionado.buscarPorId(position).getId(), Toast.LENGTH_SHORT).show();
    // Toast.makeText(getContext(), "item unico selecionado" + mList.get(position).getId(), Toast.LENGTH_SHORT).show();
    // Toast.makeText(getContext(),  mList.get(position).getOpm() + " - " + mList.get(position).getEndereco() + " - " +  mList.get(position).getBairro()+ " - " +  mList.get(position).getMunicipio() , Toast.LENGTH_SHORT).show();
    // Toast.makeText(getActivity(), "onClickListener(): " + position, Toast.LENGTH_SHORT).show();
    //sededaoselecionado = new SedeDao(getContext());

    //Bundle bundle = new Bundle();
    // bundle.putInt("iditem", 10);
    //mList.get(position).getId()
    // bundle.putInt("iditem", itemdaoDaoselecionado.buscarPorId(position).getId());
    //bundle.putInt("iditem", mList.get(position).getId());
    //fragment = new LeiFragment();
    // fragment.setArguments(bundle);
    // replaceFragment();
    // }


    //URLEncoder.encode("your URL here", "UTF8")
    //String s;
    //Sede sd;
    //SedeDao sddao;
    //sd = new Sede;
    //s = mList.get(position).getEndereco();
    //s= URLEncoder.encode(" "+s, "UTF8")


    //Avallie
    /*
            String my_package_name;
            String url;
            my_package_name="com.google.android.apps.maps";
            try {
                //Check whether Google Play store is installed or not:
                view.getContext().getPackageManager().getPackageInfo("com.google.android.apps.maps", 0);

                url = "market://details?id=" + my_package_name;
            } catch ( final Exception e ) {
                url = "https://play.google.com/store/apps/details?id=" + my_package_name;
            }

*/

    //  Uri gmmIntentUri = Uri.parse("google.navigation:q="+s+","+mList.get(position).getBairro() +" "+  mList.get(position).getMunicipio());
    //Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
    //mapIntent.setPackage("com.google.android.apps.maps");
    //if (mapIntent.resolveActivity(getContext().getPackageManager()) != null) {
    //  startActivity(mapIntent);
    //}






  }

  public void alert(View v, String s) {
    final AlertDialog dialog = new AlertDialog.Builder(v.getContext())
      .setView(R.layout.custom_dialog_layout)
      .create();

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(v.getContext());
    //alertDialogBuilder.setView((R.layout.custom_dialog_layout));
    alertDialogBuilder.setMessage(s);
    // alertDialogBuilder.setView(R.layout.custom_dialog_layout);
    // AlertDialog alertDialog = alertDialogBuilder.create();
    // setView(mLayoutInflater.createView(R.layout.custom_dialog_layout, null));
    //  alertDialog.setView(v.);
    alertDialogBuilder.show();
  }

  private void replaceFragment() {
    FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
    fragmentManager.beginTransaction()
      .replace(R.id.container, fragment)
      .commit();
  }



  private static class RecyclerViewTouchListener implements RecyclerView.OnItemTouchListener {
    private Context mContext;
    private GestureDetector mGestureDetector;
    private RecyclerViewOnClickListenerHack mRecyclerViewOnClickListenerHack;

    public RecyclerViewTouchListener(Context c, final RecyclerView rv, RecyclerViewOnClickListenerHack rvoclh) {
      mContext = c;
      mRecyclerViewOnClickListenerHack = rvoclh;

      mGestureDetector = new GestureDetector(mContext, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public void onLongPress(MotionEvent e) {
          super.onLongPress(e);

          View cv = rv.findChildViewUnder(e.getX(), e.getY());

          if (cv != null && mRecyclerViewOnClickListenerHack != null) {
            mRecyclerViewOnClickListenerHack.onLongPressClickListener(cv,
              rv.getChildPosition(cv));
          }
        }

        @Override
        public boolean onSingleTapUp(MotionEvent e) {
          View cv = rv.findChildViewUnder(e.getX(), e.getY());

          if (cv != null && mRecyclerViewOnClickListenerHack != null) {
            mRecyclerViewOnClickListenerHack.onClickListener(cv,
              rv.getChildPosition(cv));
          }

          return (true);
        }
      });
    }

    @Override
    public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
      mGestureDetector.onTouchEvent(e);
      return false;
    }

    @Override
    public void onTouchEvent(RecyclerView rv, MotionEvent e) {}

    @Override
    public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

    }
  }


}

item_legislacao.xml

 <
  android.support.v7.widget.CardView xmlns: android = "http://schemas.android.com/apk/res/android"
xmlns: tools = "http://schemas.android.com/tools"
xmlns: card_view = "http://schemas.android.com/apk/res-auto"
android: layout_gravity = "center"
android: layout_width = "match_parent"
android: layout_height = "wrap_content"
card_view: cardCornerRadius = "3dp"
card_view: cardElevation = "1.5dp"
card_view: cardUseCompatPadding = "true" >

  <
  LinearLayout
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: orientation = "vertical"
android: layout_margin = "18dp" >

  <
  TextView
android: textColor = "#000000"
android: id = "@+id/tv_model"
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: textSize = "15sp" / >

  <
  TextView
android: layout_width = "match_parent"
android: layout_height = "wrap_content"
android: id = "@+id/endereco"
android: textSize = "15sp"
android: textColor = "#000" / >

  <
  LinearLayout
android: orientation = "horizontal"
android: layout_width = "fill_parent"
android: layout_height = "30dp"
android: layout_gravity = "center_vertical"
android: gravity = "center"
android: layout_marginTop = "4dp" >

  <
  ImageButton
android: id = "@+id/imgrota"
android: theme = "@style/AppTheme.Button"
android: src = "@android:drawable/ic_dialog_map"
android: layout_height = "fill_parent"
android: layout_width = "0dip"
android: layout_weight = "1"
android: adjustViewBounds = "true"
android: padding = "2dp"
android: scaleType = "fitCenter" / >

  <
  ImageButton
android: id = "@+id/imgtel"
android: src = "@android:drawable/ic_menu_call"
android: theme = "@style/AppTheme.Button"
android: layout_height = "fill_parent"
android: layout_width = "0dip"
android: layout_weight = "1"
android: adjustViewBounds = "true"
android: padding = "2dp"
android: scaleType = "fitCenter" / >

  <
  ImageButton
android: id = "@+id/imginfo"
android: src = "@android:drawable/ic_dialog_info"
android: theme = "@style/AppTheme.Button"
android: layout_height = "fill_parent"
android: layout_width = "0dip"
android: layout_weight = "1"
android: adjustViewBounds = "true"
android: padding = "2dp"
android: scaleType = "fitCenter" /
  >

  <
  ImageButton
android: id = "@+id/imgshare"
android: src = "@android:drawable/ic_menu_share"
android: layout_height = "fill_parent"
android: layout_width = "0dip"
android: layout_weight = "1"
android: theme = "@style/AppTheme.Button"
android: adjustViewBounds = "true"
android: padding = "2dp"
android: scaleType = "fitCenter" / >

  <
  /LinearLayout>

  <
  /LinearLayout>

SedeAdapter.java

myViewHolder.btninfo.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {

    SedeFragment sedefragment;
    sedefragment = new SedeFragment();
    String s;
    s = (mList.get(position).getOpm() + "\n" + "\n" + "Endereço:" + " + mList.get(position).getEndereco() + "\
      n " +
      "Bairro:" + mList.get(position).getBairro() + "\n" + "Município:" + mList.get(position).getMunicipio() + "\n" + "\n" +
      "SOP/OF DE DIA:" + mList.get(position).getTel());
    sedefragment.alert(v, s);


  }
});

styles.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>


</style>


<style name="AppTheme.Button" parent="Base.Widget.AppCompat.Button" >
    <item name="colorButtonNormal">#FF424242</item>
    <item name="android:textColor">@android:color/white</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

Usar:

the output is:

    
asked by anonymous 13.03.2017 / 20:33

1 answer

3

Friend, try changing this theme style, android: theme = "@style/AppTheme.Button" , I've been through a problem like this, or just delete this line.

    
13.03.2017 / 23:17