Hello, how to combine 2 codes into one. Conflict of one class name. Need Fragment and Activity. public class Set1 extends Fragment
public class Set1 extends Activity
1 part
public class Set1 extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View set1 = inflater.inflate(R.layout.set1_frag, container, false); return set1; }} 2 part of the code (must be combined with 1)
public class Set1 extends Activity { Button btnLogout; Button changepas; /** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); changepas = (Button) findViewById(R.id.btchangepass); btnLogout = (Button) findViewById(R.id.logout); DatabaseHandler db = new DatabaseHandler(getApplicationContext()); /** * Hashmap to load data from the Sqlite database **/ HashMap<String,String> user = new HashMap<String, String>(); user = db.getUserDetails(); /** * Change Password Activity Started **/ changepas.setOnClickListener(new View.OnClickListener(){ public void onClick(View arg0){ Intent chgpass = new Intent(getApplicationContext(), ChangePassword.class); startActivity(chgpass); } }); /** *Logout from the User Panel which clears the data in Sqlite database **/ btnLogout.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { UserFunctions logout = new UserFunctions(); logout.logoutUser(getApplicationContext()); Intent login = new Intent(getApplicationContext(), Login.class); login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(login); finish(); } }); /** * Sets user first name and last name in text view. **/ final TextView login = (TextView) findViewById(R.id.textwelcome); login.setText("Welcome "+user.get("fname")); final TextView lname = (TextView) findViewById(R.id.lname); lname.setText(user.get("lname")); }} Update
I will try to explain in detail and normally. I had two parts of the code, I combined them. it was registration and menu (top menu), then I created 4 submenus (main, main, spare, settings). The problem arose from the submenu - settings. Copied .xml registration settings code. I decided to combine the code that relates to the menu with the registration settings. But I got stuck with a problem. If you rename Fragment into Activity, then a lot of errors come out. I can not combine it. By this turned for help laying out fragments of the application.