-2
私のカスタムアラートダイアログでRecyclerViewを実装しようとしています。エラーは、この行に
Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)' on a null object reference
と呼ば
hsv_font_bartextview.setLayoutManager(layoutManager);
カスタム対話のMy機能コードは次のようにある以下の
private void showGotoPageDialog() {
final Dialog mDialog = new Dialog(SettingsActivity.this);
mDialog.setContentView(R.layout.font_dialogue);
mDialog.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayoutManager layoutManager
= new LinearLayoutManager(SettingsActivity.this, LinearLayoutManager.HORIZONTAL, false);
hsv_font_bartextview=(RecyclerView)findViewById(R.id.hsv_font_bartextview);
hsv_font_bartextview.setLayoutManager(layoutManager);
TextAdapterTextview textAdaptertextview = new TextAdapterTextview(SettingsActivity.this, Globle.getFontArray());
hsv_font_bartextview.setAdapter(textAdaptertextview);
textAdaptertextview.setOnClickLIstner(new OnTClickLIstner() {
@Override
public void onClick(View v, String image, int position) {
Toast.makeText(SettingsActivity.this,image,Toast.LENGTH_SHORT).show();
}
});
mDialog.show();
TextView dismiss = (TextView) mDialog.findViewById(R.id.dialog_dismiss);
dismiss.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mDialog.dismiss();
}
});
}
誰かが私の問題を解決するために私を助けることができるかどうか教えてください。おかげ
'hsv_font_bartextview =(RecyclerView)mDialog.findViewById(R.id.hsv_font_bartextview)を試してみてください;'、あなたが正しいです@MichaelDoddあなたのビューがR.layout.font_dialogue' –
'内で定義されていると仮定すると...おかげ – Priya