java - How do i call my fragment class in android? -


i in mainactivity.java class , need call fragments inside mainactivity according user click list view item.is there way starting activity using intent calling fragment inside in mainactivity class?

 private void onlistitemclicked(int index) {     if(index==0){         intent one=new intent();         one.setclass(mainactivity.this,firstactivity.class);      }else{         intent two=new intent();         two.setclass(mainactivity.this,secondactivity.class);      } 

here code.for 1 use starting activity.but need start calling fragment..is there way?

for adding fragment activity

fragment newfragment = new fragment();             fragmenttransaction ft = getfragmentmanager().begintransaction();             ft.add(content_view_id, newfragment).commit(); 

where content_view_id id of container in want add fragment.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -