Ami*_*Pal 5 java android popupwindow android-layout android-activity
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="2dp"
app:cardUseCompatPadding="true">
<android.support.v7.widget.RecyclerView
android:id="@+id/landmarkView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_take_photo_surrounding"/>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
上面的代码是为 How 设计的PopUpWindow。我打开这个PopWindows上EditText.addTextChangedListener.onTextChanged()通过调用下面的方法:
private void popupWindow() {
int popupwindowHeight = LinearLayout.LayoutParams.WRAP_CONTENT;
LayoutInflater layoutInflater = (LayoutInflater) getActivity()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(
R.layout.dashboard_profile_popup_window, null);
final PopupWindow pwindow = new PopupWindow(layout, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
pwindow.setHeight(popupwindowHeight);
pwindow.setFocusable(true);
pwindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
//TODO dismiss settings
}
});
RecyclerView landmarkRecyclerView = (RecyclerView) layout.findViewById(R.id.landmarkView);
List<String> data = new ArrayList<String>();
data.add("my data");
data.add("set Data");
landmarkRecyclerView.setAdapter(new LandmarkRecyclerViewAdapter(data, getContext()));
pwindow.setWindowLayoutMode(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
pwindow.setHeight(1);
pwindow.setWidth(1);
pwindow.showAtLocation(layout, Gravity.NO_GRAVITY, mPoint.x, mPoint.y);
pwindow.showAsDropDown(place_pop_up);
}
Run Code Online (Sandbox Code Playgroud)
PopUpWindow文本更改侦听器上的空白。我在这里做错了什么?
添加LandMarkRecyclerViewAdapter过
public class LandmarkRecyclerViewAdapter extends RecyclerView.Adapter<LandmarkRecyclerViewAdapter.ViewHolder> {
private Context mContext;
private List<String> mLocalityEntities;
public LandmarkRecyclerViewAdapter(List<String> localityEntityList, Context context){
this.mContext = context;
this.mLocalityEntities = localityEntityList;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.landmark_view_adapter, null);
ViewHolder holder = new ViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
if( null != mLocalityEntities.get(position)){
holder.mTextView.setText(mLocalityEntities.get(position).toString());
}
}
@Override
public int getItemCount() {
return mLocalityEntities.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView mTextView;
public ViewHolder(View itemView) {
super(itemView);
mTextView = (TextView) itemView.findViewById(R.id.landmarkText);
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2103 次 |
| 最近记录: |