I try to edit my TextViews from another class.
It is a RecyclerView Adapter. When I click on "delete" an server gets deleted. Also some buttons and text should get invisible on the UI.
protected MainActivity context;
public ContactsAdapter(Context context){
this.context = (MainActivity) context;
}
public void onBindViewHolder(ContactsAdapter.ViewHolder viewHolder,final int position) {
...
final Handler mHandler = new Handler();
new Thread(new Runnable() {
@Override
public void run () {
mHandler.post(new Runnable() {
@Override
public void run () {
TextView commandrun = (TextView) context.findViewById(R.id.command_run);
commandrun.setVisibility(View.INVISIBLE);
}
});
}
}).start();
Actually I get java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View com.minvercraft.minvercraftfree.MainActivity.findViewById(int)' on a null object reference
.