Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
J Smillie
Courses Plus Student 40,123 PointsCan't get the right answer... for some reason
Now switch to MainActivity. This class implements ActionBar.TabListener. Add a 'Log.i()' statement in the appropriate method when a new tab is selected. Log the message "New tab!" using the TAG for this class.
For some reason this isn't the correct answer. Please can someone tell me what I'm missing here?
This is my code:
'''java
import android.app.ActionBar; import android.app.Activity; import android.app.FragmentTransaction; import android.os.Bundle; import android.util.Log;
public class MainActivity extends Activity implements ActionBar.TabListener {
public static final String TAG = MainActivity.class.getSimpleName();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
Log.i("New tab!");
}
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
}
'''
3 Answers
Amin Lalji
1,350 PointsIt appears you left off the TAG parameter in your log statement.
How about:
Log.i(TAG, "New tab!");
This prefixes the classname to the beginning of the log statement and allows you to quickly filter.
HTH
J Smillie
Courses Plus Student 40,123 Pointshappy days! thanks a lot!
MUZ140663 Question Ngwarati
11,782 PointsDankio!!!!!!!!!!!