I am working on application which have same header in all activites,in which there are some views in image views, buttons, textviews etc.
Now the The question is i want to use these header views in all the activites,but i do not want to re-code and re-design it in every activity.so is it possible to create a fragment of header views and reuse its ui and functionalities in all other activites.
thanks for the help.!
updates in this question according to my research! i have researched and fond that it can easily acheived by using fragments.but i am still not getting that how? how can i acheive that functionality? according to this: reusable UI in android app
and this:
any links and code would be helpful!
guyz i got my answer one of my friend shared a link with me which have solved my problem
the link is: same header on all the activites working like same on all
Complete Answer after applying:
this is BaseActivity class used to give functionalities to header
abstract public class BaseActivity extends Activity{
ImageView imVBattery,imVWIFI,imVSabaqLogo;
Button btnSettings,btnTheme;
WifiManager wifiManager;
//set resources to all the contols
public void setHeader(){
imVBattery=(ImageView)findViewById(R.id.imVBattery);
imVWIFI=(ImageView)findViewById(R.id.imVWIFI);
imVSabaqLogo=(ImageView)findViewById(R.id.imVSabaqLogo);
btnSettings=(Button)findViewById(R.id.btnSettings);
btnTheme=(Button)findViewById(R.id.btnTheme);
wifiManager= (WifiManager)this.getSystemService(getBaseContext().WIFI_SERVICE);
}
}
and this is my main class in which i extends this base activity:
public class Main extends BaseActivity implements OnClickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.s_main);
//with the help of this i assign all resources to controls of headers
setHeader();
}
}
thanks to all who replied and helped me.!