質問するログイン新規登録

Q&A

0回答

670閲覧

Appcelerator(Titanium)のListView templateで自動でのスクロールが出来ない。

mmagic

総合スコア4

Titanium Mobile

Titanium Mobileとは、JavaScriptでAndroidやiOSアプリケーションを開発するための開発環境です。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

0グッド

0クリップ

投稿2021/08/31 07:16

0

0

前提・実現したいこと

Appcelerator(titnium)でAndroidタブレットでの
システムを作っています。

listview Templateを使用した機能で
スクロールバーを実装したいと考えております。

スクロールバーを実装し、画面を自動で
上下にスクロールすることを行いたいのですが、
ボタンを配置し、ボタンをクリックしたイベントを実行してみても
スクロールしません。

該当のソースコード

JavaScript

1var win = Ti.UI.createWindow({backgroundColor: 'white'}); 2var plainTemplate = { 3 childTemplates: [ 4 { 5 type: 'Ti.UI.Label', // Use a label 6 bindId: 'rowtitle', // Bind ID for this label 7 properties: { // Sets the Label.left property 8 left: '10dp' 9 } 10 }, 11 { 12 type: 'Ti.UI.ImageView', // Use an image view 13 bindId: 'pic', // Bind ID for this image view 14 properties: { // Sets the ImageView.image property 15 image: 'KS_nav_ui.png' 16 } 17 }, 18 { 19 type: 'Ti.UI.Button', // Use a button 20 bindId: 'button', // Bind ID for this button 21 properties: { // Sets several button properties 22 width: '80dp', 23 height: '30dp', 24 right: '10dp', 25 title: 'press me' 26 }, 27 events: {click: report} // Binds a callback to the button's click event 28 } 29 ] 30}; 31function report(e) { 32 Ti.API.info(e.type); 33 var item = e.section.getItemAt(e.itemIndex); 34 if (item.properties.accessoryType == Ti.UI.LIST_ACCESSORY_TYPE_NONE) { 35 item.properties.accessoryType = Ti.UI.LIST_ACCESSORY_TYPE_CHECKMARK; 36 } 37 else { 38 item.properties.accessoryType = Ti.UI.LIST_ACCESSORY_TYPE_NONE; 39 } 40 e.section.updateItemAt(e.itemIndex, item); 41 alert( 42 "ItemId: " + e.itemId + "\n" + 43 "BindId: " + e.bindId + "\n" + 44 "Section Index: " + e.sectionIndex + ", Item Index: " + e.itemIndex 45 46 ); 47 listView.scrollToItem(0,0); 48} 49var listView = Ti.UI.createListView({ 50 // Maps the plainTemplate object to the 'plain' style name 51 templates: {'plain': plainTemplate}, 52 // Use the plain template, that is, the plainTemplate object defined earlier 53 // for all data list items in this list view 54 defaultItemTemplate: 'plain' 55}); 56var sectionData = []; 57var i = 25; 58for (var k = 0; k < 25; k++) { 59 var section = Ti.UI.createListSection(); 60 section.setItems([{ 61 properties: { 62 title: 'Row ' + (k + 1) 63 }, 64 rowtitle: { 65 text: 'Row ' + (k + 1) 66 } 67 }]); 68 sectionData.push(section); 69} 70listView.setSections(sectionData); 71 72// Set the initial item threshold 73listView.setMarker({sectionIndex: (i - 1), itemIndex: 0}); 74 75// Load more data and set a new threshold when item threshold is reached 76listView.addEventListener('marker', function (e) { 77 Ti.API.info("marker Fired when the list view displays the reference item or an item beyond the reference item."); 78 var max = i + 25; 79 var data = []; 80 for (var k = i; k < max; k++) { 81 var section = Ti.UI.createListSection(); 82 section.setItems([{ 83 properties: { 84 title: 'Row ' + (k + 1) 85 }, 86 rowtitle: { 87 text: 'Row ' + (k + 1) 88 } 89 }]); 90 listView.appendSection(section); 91 Ti.API.info('Row ' + (k + 1)); 92 } 93 i = i + 25; 94 listView.setMarker({sectionIndex: (i - 1), itemIndex: 0}); 95}); 96 97win.add(listView); 98win.open(); 99 100

試したこと

listView.scrollToItem(0,0);
以外でスクロールが出来そうなメソッド等をかなり時間をかけて
探しましたが見つかりませんでした。

補足情報(Titanium Appcelerator Axway Appcelerator Studio, build: 6.0.0.202005141803)

そもそもスクロールバーがlistview Templateに標準で実装されて
いないのか自分で表示しきれていないだけなのかありますが、
何とかして、スクロールバーを実装する方法を探している状況です。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.29%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問