Use like this:
class Main extends FragmentActivity {
public ImageView imageView;
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
setContentView(R.layout.main);
imageView = (ImageView)findViewById(R.id.ivMain);
}
}
class Demo extends Fragment {
Main main;
public void onAttach(Activity activity) {
main = (Main) activity;
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
main.imageView.setBackgroundColor(color);
return super.onCreateView(inflater, container, savedInstanceState);
}
}
solved How to change the activity background from fragment inside it [closed]