Wednesday, April 17, 2013

[android help] Android: DialogFragment and universal xml

Android: DialogFragment and universal xml - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















I am trying to take control of the database in android with Dialog Fragments. I mean, for example to add a new record I will click a button and pop-up fragment appears asking me for the specific fields. I click ok which fires the method in my hosting activity. That part works.


However, I also want to have other operations like delete, update, search record ect.


Is there a way to have a universal code for fragment but then assign different xml according to different database operations? I am looking for the most efficient way around my problem.


Thanks!


























You can inflate different views on your Fragment...



public class MyClass extends Fragment {
String xmlToLoad;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstances);
Bundle data = getArguments();
xmlToLoad = data.getString("what you set in your fragments pager");
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if(xmlToLoad.equals("whatever")) {
View view = inflater.inflate(R.layout.thisXML, container,false);
}
}
}



















default






.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...