Resources $ NotFoundException: Resource ID # 0x7f060007 type # 0x12 is not valid

2

When finished creating a listFragment and calling it in main apk ends giving the error below:

HereismyListFragment:

ArrayList<HashMap<String,String>>data=newArrayList<HashMap<String,String>>();SimpleAdapteradapter;String[]atividades=newString[]{"item1", "item2", "item3"};
int[] imageId = {
        R.drawable.imagem1,
        R.drawable.image2,
        R.drawable.image3,
  };

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

    HashMap<String, String> map = new HashMap<String, String>();
    for (int i = 0; i < atividades.length; i++) {
        map = new HashMap<String, String>();
        map.put("atividade", atividades[i]);
        map.put("imagem", Integer.toString(imageId[i]));
        data.add(map);
    }
    String[] from = {"atividade", "imageId"};
    int[] to = {R.id.txt, R.id.img};
    adapter = new SimpleAdapter(getActivity(), data, R.id.listView, from, to);
    setListAdapter(adapter);
    return super.onCreateView(inflater, container, savedInstanceState);
}

and my main class:

public class MainActivity extends AppCompatActivity
    implements NavigationView.OnNavigationItemSelectedListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    FirstFragment fragment = new FirstFragment();
    android.support.v4.app.FragmentTransaction fragmentTransaction =
            getSupportFragmentManager().beginTransaction();
    fragmentTransaction.replace(R.id.fragment_container, fragment);
    fragmentTransaction.commit();
    
asked by anonymous 07.06.2016 / 17:09

1 answer

3

No SimpleAdapter , a layout should be passed, not a id :

adapter = new SimpleAdapter(getActivity(), data, R.id.listView, from, to);

To fix:

adapter = new SimpleAdapter(getActivity(), data, R.layout.layout_da_lista, from, to);
    
07.06.2016 / 17:49