fragment_available_history
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/drop"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:weightSum="2">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="ALL"
android:id="@+id/texter"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/mostgrey"
android:layout_marginTop="3dp"
android:textAlignment="center"
android:layout_weight="1"/>
<android.support.v7.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_weight="1"
android:src="@drawable/downchevron"
android:layout_marginTop="2dp"
android:layout_height="wrap_content" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_below="@+id/drop"
android:layout_marginTop="5dp"
android:id="@+id/recyclerView"
android:layout_height="match_parent"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
AvailableHistoryFragment.java
public class AvailableHistoryFragment extends android.support.v4.app.Fragment {
private RecyclerView recyclerView;
//SQLiteDB db;
View drop;
String options[] = {"ALL","LIKED","CONNECTED","PASSED","EXPIRED"};
ArrayList<MatchModel> matchList = new ArrayList<>();
ArrayList<MatchModel> selectedOptionMatchList = new ArrayList<>();
String selectedOption = "ALL";
AppCompatTextView appCompatTextView;
ArrayList<String> imageUrl = new ArrayList<>();
ArrayList<Integer> isInterestedStatus = new ArrayList<>() ;
ArrayList<String> selectedOptionImageUrl =new ArrayList<>();
ArrayList<Integer> selectedOptionIsInterestedStatus =new ArrayList<>();
public static View.OnClickListener onClickListener;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_available_history, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
drop = view.findViewById(R.id.drop);
appCompatTextView = (AppCompatTextView) view.findViewById(R.id.texter);
LoggedInActivity.floatingActionButton.setVisibility(View.GONE);
initializeData();
initializeForm();
final DialogueListAdapter dialogueListAdapter = new DialogueListAdapter(getActivity(), options);
drop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builderSingle = new AlertDialog.Builder(
getActivity());
builderSingle.setAdapter(dialogueListAdapter,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String name = dialogueListAdapter.getItem(which);
appCompatTextView.setText(name);
updateRecyclerView(name);
dialog.dismiss();
}
});
builderSingle.create();
builderSingle.show();
}
});
return view;
}
}
adapter_dialogue_list.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@color/white"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:layout_height="wrap_content"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:textColor="@color/dialogue_list"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginTop="5dp"
android:textAlignment="center"
android:layout_marginBottom="5dp"
android:id="@+id/data_text"
/>
</RelativeLayout>
DialogueListAdapter
public class DialogueListAdapter extends ArrayAdapter<String> {
private final Activity activity;
private final String[] data;
public DialogueListAdapter(Activity activity, String[] data) {
super(activity, R.layout.adapter_dialogue_list, data);
this.activity = activity;
this.data = data;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = activity.getLayoutInflater();
View rowView= inflater.inflate(R.layout.adapter_dialogue_list, null, true);
TextView textTitle = (TextView) rowView.findViewById(R.id.data_text);
textTitle.setText(data[position]);
return rowView;
}
}
主题
<resources>
<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="AppFullScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<style name="mystyle" parent="Widget.AppCompat.Button.Colored">
<item name="android:textColor">#FFFFFF</item>
<item name="colorButtonNormal">#1E9CFD</item>
</style>
<style name="myster" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
</style>
<style name="MySwitch" parent="Theme.AppCompat.Light">
<!-- active thumb & track color (30% transparency) -->
<item name="colorControlActivated">@color/most_used</item>
<!-- inactive thumb color -->
<item name="colorSwitchThumbNormal">@color/mostgrey</item>
<!-- inactive track color (30% transparency) -->
<item name="android:colorForeground">@color/mostgrey</item>
</style>
</resources>
我在Android API级别的对话框中获得黑色背景 25电话。你可以帮忙删除它。我试过设置 片段中的xml背景颜色以及对话框 列表适配器。查找附加的屏幕截图以检查顶部和底部 黑线。我的AppTheme是“AppTheme”,片段主题是“神秘”
答案 0 :(得分:0)
我认为这样可以解决问题。
AlertDialog.Builder builderSingle = new AlertDialog.Builder(
this);
builderSingle.setAdapter(dialogueListAdapter,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String name = dialogueListAdapter.getItem(which);
appCompatTextView.setText(name);
updateRecyclerView(name);
dialog.dismiss();
}
});
AlertDialog alertDialog = builderSingle.create();
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
alertDialog.show();