我正在使用Roughike底部栏,并尝试使用xml >>选项卡。我无法导航至底部栏中的其他选项卡,我单击了特定图标,但没有任何反应。请检查并告知。如果您需要进一步的信息,也请告诉我。
MainActivity.java
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.widget.Toast;
import com.example.vt.HomeFragment;
import com.roughike.bottombar.BottomBar;
import com.roughike.bottombar.OnTabSelectListener;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelected(@IdRes int tabId) {
if (tabId == R.id.tab_home){
Intent homeIntent = new Intent(MainActivity.this, HomeFragment.class);
startActivity(homeIntent);
} else if (tabId == R.id.tab_gallery){
Toast.makeText(getBaseContext(),"Gallery",Toast.LENGTH_SHORT).show();
} else if (tabId == R.id.tab_profile){
Intent profileIntent = new Intent(MainActivity.this, MyProfile.class);
startActivity(profileIntent);
} else if(tabId == R.id.tab_location){
Intent locationIntent = new Intent(MainActivity.this, LocationFragment.class);
startActivity(locationIntent);
}
}
});
}
}
答案 0 :(得分:0)
不建议使用Roughike底栏。建议使用BottomNavigationView。