當前位置: 首頁>>代碼示例>>Java>>正文


Java NavUtils類代碼示例

本文整理匯總了Java中android.support.v4.app.NavUtils的典型用法代碼示例。如果您正苦於以下問題:Java NavUtils類的具體用法?Java NavUtils怎麽用?Java NavUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NavUtils類屬於android.support.v4.app包,在下文中一共展示了NavUtils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        // Respond to the action bar's Up/Home button
        case android.R.id.home:
            Intent upIntent = NavUtils.getParentActivityIntent(this);
            upIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
                // This activity is NOT part of this app's task, so create a new task
                // when navigating up, with a synthesized back stack.
                TaskStackBuilder.create(this)
                        // Add all of this activity's parents to the back stack
                        .addNextIntentWithParentStack(upIntent)
                        // Navigate up to the closest parent
                        .startActivities();
            } else {
                // This activity is part of this app's task, so simply
                // navigate up to the logical parent activity.
                NavUtils.navigateUpTo(this, upIntent);
            }
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:FeedActivity.java

示例2: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
		case R.id.action_joystick:
			setCurrentFragment(FRAGMENT_JOYSTICK);
			break;

		case R.id.action_arrows:
			setCurrentFragment(FRAGMENT_ARROWS);
			break;

		case android.R.id.home:
			NavUtils.navigateUpFromSameTask(this);
			break;
	}

	return true;
}
 
開發者ID:Make-A-Pede,項目名稱:Make-A-Pede-Android-App,代碼行數:19,代碼來源:ControllerActivity.java

示例3: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }
    //noinspection SimplifiableIfStatement
    if (id == android.R.id.home) {

        NavUtils.navigateUpFromSameTask(this);
    }

    return super.onOptionsItemSelected(item);
}
 
開發者ID:vikasdesale,項目名稱:Wings2K16,代碼行數:20,代碼來源:Developer.java

示例4: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }
    //noinspection SimplifiableIfStatement
    if (id == android.R.id.home) {

        NavUtils.navigateUpFromSameTask(this);
        overridePendingTransition(R.drawable.from_middle, R.drawable.to_middle);

    }
    return super.onOptionsItemSelected(item);
}
 
開發者ID:vikasdesale,項目名稱:Wings2K16,代碼行數:21,代碼來源:EventViewActivity.java

示例5: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  int id = item.getItemId();
  if (id == android.R.id.home) {
    // This ID represents the Home or Up button. In the case of this
    // activity, the Up button is shown. Use NavUtils to allow users
    // to navigate up one level in the application structure. For
    // more details, see the Navigation pattern on Android Design:
    //
    // http://developer.android.com/design/patterns/navigation.html#up-vs-back
    //
    NavUtils.navigateUpTo(this, new Intent(this, SimpleListActivity.class));
    return true;
  }
  return super.onOptionsItemSelected(item);
}
 
開發者ID:charlesng,項目名稱:SampleAppArch,代碼行數:17,代碼來源:SimpleDetailActivity.java

示例6: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            NavUtils.navigateUpFromSameTask(this);
            return true;
        case R.id.menu_delete:
            promptForDelete();
            return true;
        case R.id.menu_enable_nfc:
            Intent intent = new Intent(this, NfcNotEnabledActivity.class);
            startActivity(intent);
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:18,代碼來源:RepoDetailsActivity.java

示例7: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(@NonNull final MenuItem item)
{
	switch (item.getItemId())
	{
		case android.R.id.home:
			NavUtils.navigateUpFromSameTask(this);
			return true;

		case R.id.action_rescan:
			final BaseAdapter adapter = Providers.makeAdapter(this, R.layout.item_providers, from, to, true);
			final ListView listView = findViewById(R.id.providers);
			listView.setAdapter(adapter);
			return true;
	}
	return super.onOptionsItemSelected(item);
}
 
開發者ID:1313ou,項目名稱:Treebolic,代碼行數:18,代碼來源:ProvidersActivity.java

示例8: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case zz.aimsicd.lite.R.id.action_send_logs:
            sendEmail();
            return true;

        case android.R.id.home:
            // This ID represents the Home or Up button. In the case of this
            // activity, the Up button is shown. Use NavUtils to allow users
            // to navigate up one level in the application structure. For
            // more details, see the Navigation pattern on Android Design:
            //
            // http://developer.android.com/design/patterns/navigation.html#up-vs-back
            //
            NavUtils.navigateUpFromSameTask(this);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:21,代碼來源:DebugLogs.java

示例9: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        //
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        NavUtils.navigateUpTo(this, new Intent(this, ItemListActivity.class));
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:17,代碼來源:ItemDetailActivity.java

示例10: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    try {
        switch (item.getItemId()) {
            case R.id.howToItem:
                Common.previousActivity = DotsLayoutActivity.class;
                Intent howToIntent = new Intent(this, WebViewActivity.class);
                howToIntent.putExtra("activity_title", getString(R.string.how_to_item));
                howToIntent.putExtra("web_url", getString(R.string.how_to_link));
                startActivity(howToIntent);
                break;
            case android.R.id.home:
                NavUtils.navigateUpFromSameTask(this);
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return true;
}
 
開發者ID:MohammadAlBanna,項目名稱:Swift-Braille-Soft-keyboard,代碼行數:21,代碼來源:DotsStyleActivity.java

示例11: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    try {
        switch (item.getItemId()) {
            case R.id.howToItem:
                Common.previousActivity = KeyboardDimensionActivity.class;
                Intent howToIntent = new Intent(this, WebViewActivity.class);
                howToIntent.putExtra("activity_title", getString(R.string.how_to_item));
                howToIntent.putExtra("web_url", getString(R.string.how_to_link));
                startActivity(howToIntent);
                break;
            case android.R.id.home:
                NavUtils.navigateUpFromSameTask(this);
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return true;
}
 
開發者ID:MohammadAlBanna,項目名稱:Swift-Braille-Soft-keyboard,代碼行數:21,代碼來源:KeyboardDimensionActivity.java

示例12: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    try {
        switch (item.getItemId()) {
            case R.id.howToItem:
                Common.previousActivity = KeyboardLanguagesActivity.class;
                Intent howToIntent = new Intent(this, WebViewActivity.class);
                howToIntent.putExtra("activity_title", getString(R.string.how_to_item));
                howToIntent.putExtra("web_url", getString(R.string.how_to_link));
                startActivity(howToIntent);
                break;
            case android.R.id.home:
                NavUtils.navigateUpFromSameTask(this);
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return true;
}
 
開發者ID:MohammadAlBanna,項目名稱:Swift-Braille-Soft-keyboard,代碼行數:21,代碼來源:KeyboardLanguagesActivity.java

示例13: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
/**
 * Customize option bar
 * @param item
 * @return
    */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch( item.getItemId() ){
		case android.R.id.home:
			if ( NavUtils.getParentActivityName(getActivity()) != null){
				NavUtils.navigateUpFromSameTask(getActivity());
			}
			return true;
		case edu.osu.siyang.smartform.R.id.menu_item_delete_single_test:
			AlertDialog diaBox = AskOption();
			diaBox.show();
			return true;
		default:
			return super.onOptionsItemSelected(item);
	}
}
 
開發者ID:publiclab,項目名稱:SmART-Form,代碼行數:22,代碼來源:TestFragment.java

示例14: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // User clicked on a menu option in the app bar overflow menu
    switch (item.getItemId()) {
        // Respond to a click on the "Save" menu option
        case R.id.action_save:
            // insert the pet to database
            savePet();
            // close the windows with the forms
            finish();
            return true;
        // Respond to a click on the "Delete" menu option
        case R.id.action_delete:
            // Do nothing for now
            return true;
        // Respond to a click on the "Up" arrow button in the app bar
        case android.R.id.home:
            // Navigate back to parent activity (CatalogActivity)
            // if no changes, continue back to parent activity
            if (!mPetHasChanged) {
                NavUtils.navigateUpFromSameTask(EditorActivity.this);
                return true;
            }

            // if there are unsaved changes
            DialogInterface.OnClickListener discardButtonClickListener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // User clicked "Discard Button"
                    NavUtils.navigateUpFromSameTask(EditorActivity.this);
                }
            };

            // Show Dialog
            showUnsavedChangesDialog(discardButtonClickListener);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
開發者ID:gusbru,項目名稱:pets,代碼行數:40,代碼來源:EditorActivity.java

示例15: onOptionsItemSelected

import android.support.v4.app.NavUtils; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        Intent upIntent = new Intent(this, MainActivity.class);
        if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
            // This activity is not part of the application's task, so create a new task
            // with a synthesized back stack.
            TaskStackBuilder.from(this)
                    .addNextIntent(upIntent)
                    .startActivities();
            finish();
        } else {
            // This activity is part of the application's task, so simply
            // navigate up to the hierarchical parent activity.
            NavUtils.navigateUpTo(this, upIntent);
        }
        return true;
    } else if (item.getTitle().equals("Settings")) {
        //startActivity(new Intent(this, Settings.class));
        finish();
        // overridePendingTransition(R.anim.hold, R.anim.push_out_to_left);
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:26,代碼來源:AnimeDetailsActivity.java


注:本文中的android.support.v4.app.NavUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。