Last active
January 4, 2016 03:39
-
-
Save codeguru42/8563140 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup parent, | |
Bundle savedInstanceState) { | |
Log.d(TAG, "onCreateView()"); | |
View fragmentView = inflater.inflate(R.layout.image, parent, false); | |
ImageView imageView = (ImageView) fragmentView.findViewById(R.id.image); | |
imageView.setImageResource(imageId); | |
return fragmentView; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package codeguru.exercise; | |
import android.support.v4.app.Fragment; | |
import android.support.v4.app.FragmentTransaction; | |
import android.support.v7.app.ActionBar.Tab; | |
import android.support.v7.app.ActionBar.TabListener; | |
import android.util.Log; | |
public class MachineTabListener implements TabListener { | |
private static final String TAG = MachineTabListener.class.getName(); | |
private Fragment fragment; | |
public MachineTabListener(Fragment fragment) { | |
this.fragment = fragment; | |
} | |
@Override | |
public void onTabReselected(Tab tab, FragmentTransaction ft) { | |
// TODO Auto-generated method stub | |
} | |
@Override | |
public void onTabSelected(Tab tab, FragmentTransaction ft) { | |
Log.d(TAG, "Tab selected: " + tab.getText()); | |
ft.replace(R.id.fragment_container, fragment); | |
} | |
@Override | |
public void onTabUnselected(Tab tab, FragmentTransaction ft) { | |
ft.remove(fragment); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment