Creating Blank Activity


#1

Hello,

I have started reading the book, I notice that android now on kitkat while the book is on Jelly bean at most does this has any disadvantages?

Also Creating blank activity opens window that includes the creation of Fragment Layout Name? I am going to keep the defaults, but later in code shall I remove the extra stubs generated in the activity? and also the fragment xml in res directory? Or should I keep them as they are?

Thanks


#2

After Searching the internet I made the first example work finally!!!

The main activity onCreate() inflates the fragment by using a static final class PlaceHolderFragment() auto generated by the IDE
In the that class I overridden public method onActivityCreated and got reference to the views resources

[code] /**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {

	private Button mTrueButton;
	private Button mFalseButton;
	
    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_quiz, container, false);
        return rootView;
    }

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		
        mTrueButton = (Button) getView().findViewById(R.id.true_button);
        mTrueButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Toast.makeText(getActivity(), 
						R.string.incorrect_toast, 
						Toast.LENGTH_SHORT)
				.show();
				
			}
		});
        
        mFalseButton = (Button) getView().findViewById(R.id.false_button);
        mFalseButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Toast.makeText(getActivity(), 
					R.string.correct_toast,
					Toast.LENGTH_SHORT)
				.show();
				
			}
		});
	}
    
    
}[/code]

Finally I had it work, I guess now I continue with the book. BTW I find the book very interesting and helpful thanks