我想我在某个地方搞砸了。我测试正确。但是我无法找到导航中的外部链接为何停止工作的原因。抽屉打开,但是单击时没有任何反应。请帮忙。
package com.maitechbaba.vaastu.totke;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.Toast;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
/**
* Class that initializes the Categories Activity for the app.
*/
public class CategoriesActivity extends AppCompatActivity {
private DrawerLayout dl;
private ActionBarDrawerToggle t;
public NavigationView nv;
//TextView secondp;
//private InterstitialAd interstitial;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_categories);
MobileAds.initialize(this, "ca-app-pub-8135736126553624~2677944470");
AdView mAdView = (AdView) findViewById(R.id.adView2);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
// Add Back (Up) Functionality
Utils.activateBackBtn(CategoriesActivity.this, R.id.category_back_btn);
// Initiate the ViewPager
ViewPager viewPager = (ViewPager) findViewById(R.id.category_view_pager);
CategoriesAdapter adapter = new CategoriesAdapter(getSupportFragmentManager(), CategoriesActivity.this);
viewPager.setAdapter(adapter);
// Set Tab Titles
TabLayout tabLayout = (TabLayout) findViewById(R.id.category_tabs);
tabLayout.setupWithViewPager(viewPager);
// Select Tab from Intent
TabLayout.Tab tab = tabLayout.getTabAt(getIntent().getIntExtra("selected_index", 0));
if (tab != null) tab.select();
///
dl = (DrawerLayout)findViewById(R.id.activity_categories);
t = new ActionBarDrawerToggle(this, dl, R.string.Open, R.string.Close);
dl.addDrawerListener(t);
t.syncState();
nv = (NavigationView)findViewById(R.id.nv);
nv.setItemIconTintList(null);
nv.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int id = item.getItemId();
switch(id)
{
case R.id.account:
//Request new article
Intent intent = new Intent (Intent.ACTION_VIEW , Uri.parse("mailto:" + "aryan.yudi@gmail.com"));
intent.putExtra(Intent.EXTRA_SUBJECT, "Please Add New Content");
intent.putExtra(Intent.EXTRA_TEXT, "Hi , Please add following content in next update");
startActivity(intent);
finish();
return true;
case R.id.settings:
//Checkout our apps
startActivity(new Intent(CategoriesActivity.this, AppActivity.class));
return true;
//case R.id.mycart:
// Toast.makeText(MainActivity.this, "My Cart",Toast.LENGTH_SHORT).show();
case R.id.visit:
Toast.makeText(CategoriesActivity.this, "Happy Visit",Toast.LENGTH_SHORT).show();
Uri uri = Uri.parse( "https://www.maitechbaba.com" );
startActivity( new Intent( Intent.ACTION_VIEW, uri ) );
return true;
case R.id.youtube:
Toast.makeText(CategoriesActivity.this, "Thanks ",Toast.LENGTH_SHORT).show();
Uri uri3 = Uri.parse( "https://www.youtube.com/techbabakivines?sub_confirmation=1" );
startActivity( new Intent( Intent.ACTION_VIEW, uri3 ) );
return true;
case R.id.facebook:
Toast.makeText(CategoriesActivity.this, "Thank You",Toast.LENGTH_SHORT).show();
Uri uri1 = Uri.parse( "https://www.facebook.com/TechBaba7/" );
startActivity( new Intent( Intent.ACTION_VIEW, uri1 ) );
return true;
case R.id.instagram:
Toast.makeText(CategoriesActivity.this, "Thanks",Toast.LENGTH_SHORT).show();
Uri uri2 = Uri.parse( "https://www.instagram.com/maitechbaba/" );
startActivity( new Intent( Intent.ACTION_VIEW, uri2 ) );
return true;
default:return true;
}
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(t.onOptionsItemSelected(item))
return true;
return super.onOptionsItemSelected(item);
}
}
这是代码,现在我被困在这里。我检查了xml文件。这似乎也找到了,并且正如我告诉我的那样,当时它工作得很好。