Using Threads to change UI properties in fragment?
<p>I'm using handlers to change some UI properties but i cannot see any change when the app runs. why isn't the code compiling? i used handlers in my thread to change UI buttons and images. i understand for images i could easily use Bitmaps to be more efficient but im using this to learn coding with threads to improve app performance.</p>

<p>Fragments code;</p>

<pre><code>import android.media.Image;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.View;
import android.widget.TextView;
import android.widget.ImageView;
import android.widget.TextView;
import org.w3c.dom.Text;
import android.view.View;
import android.os.AsyncTask;
import java.net.URL;
import android.os.Handler;
import android.os.Message;


public class headercode extends Fragment  {

    ImageView image;
    TextView text;
    View myView;
    Thread thread;

    Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg)
        {
            image = (ImageView)myView.findViewById(R.id.image);
            image.setBackgroundResource(R.drawable.ahmed);
        }
    };


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


        myView = inflater.inflate(R.layout.frag, container, false);
        text = (TextView)myView.findViewById(R.id.text);
        Runnable r = new Runnable()
        {
            @Override
            public void run(){
                handler.sendEmptyMessage(0);
            }
        };
        return myView;
    }
}
</code></pre>

<p>Main Activity Code where i call OnCreate() of course and display the initial fragments that is created with the Activity;</p>

<pre><code>import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.FragmentManager;
import android.widget.FrameLayout;
import android.widget.Button;



public class MainActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener   {




    Button button;
    headercode header;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);



        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();



        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);

        if (findViewById(R.id.fragment) != null){

            header = new headercode();
            getSupportFragmentManager().beginTransaction().add(R.id.fragment,header).commit();
        }

    }
</code></pre>