이것은 특정 질문이지만 어쨌든 게시 ...런타임시 정적 변수 변경
런타임에 정적 변수를 변경할 수 없습니다. 내 문제는 내가 런타임에 목록보기에서 행 수를 변경할 수 없다는 것입니다. 그것은 아래 코드와 함께 작동하지만이 목록은 이제 정적입니다. 사용자가 하나의 항목을 추가하거나 제거하려는 경우이 예제의 목록에는 여전히 5 개의 행이 있습니다.
이
는 섹션의 항목에 관련된 스크립트의 라인이다 :#include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
#include "settings.h"
static Window window;
static SimpleMenuLayer menu_layer;
static SimpleMenuSection menu_sections[1];
static SimpleMenuItem menu_section0_items[5];
[...]
void init_settings_window()
[...]
menu_sections[0] = (SimpleMenuSection) {
.title = "Things to buy...",
.items = menu_section0_items,
.num_items = ARRAY_LENGTH(menu_section0_items)
};
의 정의 SimpleMenuSection (API 참조) :
struct SimpleMenuSection
Data structure containing the information of a menu section.
Data Fields
const SimpleMenuItem * items Array of items in the section.
uint32_t num_items Number of items in the .items array.
const char * title Title of the section. Optional, leave NULL if unused.
나는 런타임에 변경하고자하는 것이 무엇인지 이해하지 못합니다. –
나에게 쉽게 설명되지 않았다, 미안. 그러나 나는 그것을 (잘하면) 풀었다. 정적 SimpleMenuItem에서 menu_section0_items [5]; 섹션의 최대 항목을 설정할 수 있습니다. 이 줄에서 .items = menu_section0_items 나는 menu_section0_items를 uint32_t 변수와 교환했다. 이제 작동합니다. 아마도이 질문을 삭제하는 것이 좋습니다 :( – Peter