android应用程序中的底部导航栏

时间:2018-09-19 00:27:57

标签: android user-controls uinavigationbar logout bottomnavigationview

我开发了一个android应用程序,我需要阻止用户通过导航栏按钮关闭该应用程序。.还有另一种方法来关闭该应用程序。 我搜索了很多东西,却找不到永久隐藏底部导航栏或至少停止所有按钮控制的方法

2 个答案:

答案 0 :(得分:0)

如果要禁用设备上的后退按钮,则可以覆盖

@Override
public void onBackPressed() {
    super.onBackPressed(); //delete or comment this line
    .......//do something you want
}

答案 1 :(得分:0)

使用此方法禁用主页按钮

@model WebAppMVC.Models.Movie

@{
    ViewData["Title"] = "Create";
}

<h2>Create</h2>

<h4>Movie</h4>
<hr />
<div class="row">
    <div class="col-md-4">
        <form asp-action="Create">
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
            <div class="form-group">
                <label asp-for="Title" class="control-label"></label>
                <input asp-for="Title" class="form-control" />
                <span asp-validation-for="Title" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="ReleaseDate" class="control-label"></label>
                <input asp-for="ReleaseDate" class="form-control" />
                <span asp-validation-for="ReleaseDate" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Genre" class="control-label"></label>
                <input asp-for="Genre" class="form-control" />
                <span asp-validation-for="Genre" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Price" class="control-label"></label>
                <input asp-for="Price" class="form-control" />
                <span asp-validation-for="Price" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Rating" class="control-label"></label>
                <input asp-for="Rating" class="form-control" />
                <span asp-validation-for="Rating" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="File" class="control-label"></label>
                <input asp-for="File" />
                <span asp-validation-for="File" class="text-danger"></span> 
            </div>
            <div class="form-group">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </form>
    </div>
</div>

<div>
    <a asp-action="Index">Back to List</a>
</div>

@section Scripts{
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}


    <script type="text/javascript">
        $.validator.addMethod('sacred',
            function (value, element, params) {
                var title = $(params[0]).val(),
                    sacredword = params[1];
                if (title!=null && title == sacredword) {
                    return true;
                }
                else {
                    return false;
                }
            }
        );
        $.validator.unobtrusive.adapters.add('sacred',
            ['sacredword'],
            function (options) {
                var element = $(options.form).find('input#Title')[0];
                options.rules['sacred'] = [element, options.params['sacredword']];
                options.messages['sacred'] = options.message;
            }
        );
    </script>
}