Only the original thread that created a view hierarchy can touch its views

7 Apr

If you are geting issue like .roid “Only the original thread that created a view hierarchy can touch its views.” then its solution is that you need run you code i nUi Thread.


void testfunction() {

runOnUiThread(new Runnable() {

@Override
public void run() {

GridView gridView = (GridView) findViewById(R.id.CustomerListGridview);

AdaptorServices gridAdapter = new AdaptorServices(activity, R.layout.layout_item_service_list, products);

gridView.setAdapter(gridAdapter);

gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {

}
});

}
});

}

Leave a Reply

Your email address will not be published. Required fields are marked *

one × 1 =