は、それがエラーを示してdoesntのが、私はその後、setAdapterするために呼び出すときにその終了私のアプリ私は私のカスタムリストビューアダプタに呼び出したときに私のアプリが失敗している私は私のカスタムアダプタのコンストラクタに呼び出すとき
ListView listView =(ListView)findViewById(R.id.slistview);
EmployeeListAdapter suerveryAdapter= new EmployeeListAdapter(SuerveyUserActivity.this,arrayList,getResources());
listView.setAdapter(suerveryAdapter);
と私のカスタムアダプタクラスコードは、私は私のカスタム広告へのArrayListを渡さ
public class EmployeeListAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<serveyData> data;
private static LayoutInflater layoutInflater = null;
public Resources res;
serveyData employee;
public EmployeeListAdapter(Activity a,ArrayList d,Resources r)
{
activity = a;
data = d;
res = r;
layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
/*for (serveyData e : data) {
String NameAndEmail = data.size()+"000"+e.getId() + "," + e.getName()+ "," +e.getDesciption();
Toast.makeText(activity, NameAndEmail,Toast.LENGTH_SHORT).show();
}*/
}
@Override
public int getCount() {
return data.size();
}
@Override
public Object getItem(int position) {
return data.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
public class ViewHolder
{
public TextView tID;
public TextView tName;
public Button bDelete;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v1 = convertView;
final ViewHolder holder;
if(convertView == null)
{
v1 = layoutInflater.inflate(R.layout.single_item,null);
holder = new ViewHolder();
holder.tID = (TextView) v1.findViewById(R.id.tvID);
holder.tName = (TextView) v1.findViewById(R.id.tvName);
holder.bDelete = (Button) v1.findViewById(R.id.btnDelete);
v1.setTag(holder);
}
else
{
holder = (ViewHolder)v1.getTag();
}
if(data.size() < 1)
{
holder.tName.setText("No Data Found");
holder.bDelete.setVisibility(View.GONE);
}
else
{
employee = new serveyData();
employee = (serveyData) data.get(position);
holder.tID.setText(employee.getId());
holder.tName.setText(employee.getName());
holder.bDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/*Intent i = new Intent(activity, AddEmployee.class);
activity.startActivity(i);*/
}
});
}
return v1;
}}
とエラーログが
enter code here
1-02 21:17:50.269 2957-2957/com.example.abbkr.android2k17_proj E/AndroidRuntime: FATAL EXCEPTION: main
android.content.res.Resources$NotFoundException: String resource ID #0x1
at android.content.res.Resources.getText(Resources.java:229)
at android.support.v7.widget.ResourcesWrapper.getText(ResourcesWrapper.java:52)
at android.widget.TextView.setText(TextView.java:3620)
at com.example.abbkr.android2k17_proj.CustomAdapter.SuerveryAdapter.getView(SuerveryAdapter.java:110)
at android.widget.AbsListView.obtainView(AbsListView.java:2267)
at android.widget.ListView.makeAndAddView(ListView.java:1769)
at android.widget.ListView.fillDown(ListView.java:672)
at android.widget.ListView.fillFromTop(ListView.java:733)
at android.widget.ListView.layoutChildren(ListView.java:1622)
at android.widget.AbsListView.onLayout(AbsListView.java:2102)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1638)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1422)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:433)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1866)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1687)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik
ですので、助けてください
logcatが印刷されていますか? – iGio90
エラーは何ですか? – clearlight
リソースパスコンテキストにアクセスし、コンテキストでgetresourcesを呼び出す必要がある場合は、なぜリソースをパラメータとして渡していますか –