Я создал приложение, которое использует кнопку плавающего действия (FAB). Моя проблема в том, что FAB не работает на API
Это манифест: < /p>
< /code>
Есть два файла Gradle: < /p>
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
< /code>
и < /p>
plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "eu.mygamesapp.mygames"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1' //Needed for the Floating Action Button
}
< /code>
Это то, что должен делать Fab: < /p>
private void floatingActionButtonManagement() {
FloatingActionButton fab_addGame = (FloatingActionButton)findViewById(R.id.fab_AddGame);
fab_addGame.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/*
The currentConsole TextView is used to show at the user which console is selected.
We use it to have a string that contains the selected console.
Call the method that manage the click event of the FloatingActionButton. We pass the console name.
*/
String currentConsoleName = currentConsole.getText().toString();
floatingActionButtonClickEvent(currentConsoleName);
}
});
}
private void floatingActionButtonClickEvent(String currentConsoleName) {
/*
Check if user have added a console. If he did start a menu for adding games, else start an
error message
*/
if (!currentConsoleName.equals(TXT_MAINACTVT_USER_HAVE_NOT_ADDED_CONSOLE)) {
popUpViewAddGameBuild(currentConsoleName);
}
else
mySimpleAlertDialogMethod("Attention!", "Before you enter game, you must enter a console.", true, true);
}
private void popUpViewAddGameBuild(String currentConsoleName) {
/*
Build the view that show the menu for adding games.
*/
LayoutInflater inflater = this.getLayoutInflater();
View popupView = inflater.inflate(R.layout.popupview_addgame, null);
PopupWindow popupWindow = new PopupWindow(
popupView,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT);
popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
popupWindow.setFocusable(true);
popupWindow.showAtLocation(popupView, 0, 0, 0);
popUpAddGameSetFullAdapter(popupView, currentConsoleName);
popUpAddGameClickEventManagment(popupView, popupWindow, currentConsoleName);
}
private void popUpAddGameSetFullAdapter(View popupView, String currentConsoleName) {
/*
Fill the listView with all the games of the current console
*/
ListView lstvw_addVideoGamePopUp_listOfAllGames = (ListView) popupView.findViewById(R.id.listView_all_games);
Cursor cursor = appDataBase.getAllCurrentConsoleGames(currentConsoleName);
String[] fromFieldNames = new String[]{AppDataBase.COL_VIDEOGAME_NAME};
int[] toViewsIDs = new int[]{R.id.txt_popUpViewAddGame_lstvw_name};
SimpleCursorAdapter myCursorAdapter = new SimpleCursorAdapter(popupView.getContext(), R.layout.listview_allcurrentconsolegames, cursor, fromFieldNames, toViewsIDs, 0);
lstvw_addVideoGamePopUp_listOfAllGames.setAdapter(myCursorAdapter);
}
< /code>
Я не имею представления, в чем может быть проблема. Что мне делать?
Подробнее здесь: https://stackoverflow.com/questions/351 ... her-api-21
Кнопка «Плавающее действие» работает только на Android 5.0 или выше (API 21) ⇐ Android
Форум для тех, кто программирует под Android
1755882263
Anonymous
Я создал приложение, которое использует кнопку плавающего действия (FAB). Моя проблема в том, что FAB не работает на API
Это манифест: < /p>
< /code>
Есть два файла Gradle: < /p>
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
< /code>
и < /p>
plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "eu.mygamesapp.mygames"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1' //Needed for the Floating Action Button
}
< /code>
Это то, что должен делать Fab: < /p>
private void floatingActionButtonManagement() {
FloatingActionButton fab_addGame = (FloatingActionButton)findViewById(R.id.fab_AddGame);
fab_addGame.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/*
The currentConsole TextView is used to show at the user which console is selected.
We use it to have a string that contains the selected console.
Call the method that manage the click event of the FloatingActionButton. We pass the console name.
*/
String currentConsoleName = currentConsole.getText().toString();
floatingActionButtonClickEvent(currentConsoleName);
}
});
}
private void floatingActionButtonClickEvent(String currentConsoleName) {
/*
Check if user have added a console. If he did start a menu for adding games, else start an
error message
*/
if (!currentConsoleName.equals(TXT_MAINACTVT_USER_HAVE_NOT_ADDED_CONSOLE)) {
popUpViewAddGameBuild(currentConsoleName);
}
else
mySimpleAlertDialogMethod("Attention!", "Before you enter game, you must enter a console.", true, true);
}
private void popUpViewAddGameBuild(String currentConsoleName) {
/*
Build the view that show the menu for adding games.
*/
LayoutInflater inflater = this.getLayoutInflater();
View popupView = inflater.inflate(R.layout.popupview_addgame, null);
PopupWindow popupWindow = new PopupWindow(
popupView,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT);
popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
popupWindow.setFocusable(true);
popupWindow.showAtLocation(popupView, 0, 0, 0);
popUpAddGameSetFullAdapter(popupView, currentConsoleName);
popUpAddGameClickEventManagment(popupView, popupWindow, currentConsoleName);
}
private void popUpAddGameSetFullAdapter(View popupView, String currentConsoleName) {
/*
Fill the listView with all the games of the current console
*/
ListView lstvw_addVideoGamePopUp_listOfAllGames = (ListView) popupView.findViewById(R.id.listView_all_games);
Cursor cursor = appDataBase.getAllCurrentConsoleGames(currentConsoleName);
String[] fromFieldNames = new String[]{AppDataBase.COL_VIDEOGAME_NAME};
int[] toViewsIDs = new int[]{R.id.txt_popUpViewAddGame_lstvw_name};
SimpleCursorAdapter myCursorAdapter = new SimpleCursorAdapter(popupView.getContext(), R.layout.listview_allcurrentconsolegames, cursor, fromFieldNames, toViewsIDs, 0);
lstvw_addVideoGamePopUp_listOfAllGames.setAdapter(myCursorAdapter);
}
< /code>
Я не имею представления, в чем может быть проблема. Что мне делать?
Подробнее здесь: [url]https://stackoverflow.com/questions/35127791/floating-action-button-works-only-on-android-5-0-or-higher-api-21[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия