がサイドの引き出しなどのネイティブのAndroid引き出しレイアウトの基本的な実装であるあなたの助けをいただき、ありがとうございます。あなたに
あなたのpage.xmlで
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo">
<Placeholder creatingView="creatingView"/>
</Page>
var app = require("application");
var drawer;
var page;
var appContext;
function navigatingTo(args) {
page = args.object;
appContext = app.android.context;
}
exports.navigatingTo = navigatingTo;
function creatingView(args) {
// init DrawerLayout
drawer = new android.support.v4.widget.DrawerLayout(appContext);
var frame = new android.widget.FrameLayout(appContext);
// here you can use ListView with Adapters if you prefer
var linearMenu = new android.widget.LinearLayout(appContext);
linearMenu.setOrientation(1);
// adding the menu options
var textView1 = new android.widget.TextView(appContext);
textView1.setText("ITEM 1");
var textView2 = new android.widget.TextView(appContext);
textView2.setText("ITEM 2");
var textView3 = new android.widget.TextView(appContext);
textView3.setText("ITEM 3");
// setting layout params
var lp = new android.support.v4.widget.DrawerLayout.LayoutParams(100, android.widget.LinearLayout.LayoutParams.MATCH_PARENT);
lp.gravity = android.view.Gravity.START;
linearMenu.setLayoutParams(lp);
linearMenu.addView(textView1);
linearMenu.addView(textView2);
linearMenu.addView(textView3);
// finally adding the elements to the DrawerLayout and attaching it to the NativeScript placeholder
drawer.addView(frame, new android.support.v4.widget.DrawerLayout.LayoutParams(android.view.ViewGroup.Layou tParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT));
drawer.addView(linearMenu);
args.view = drawer;
}
exports.creatingView = creatingView;
これは無転移の効果および添付なしベントリスナーと非常に基本的な例ですが、それでもとしてスワイプで動作しますがpage.jsネイティブAPIを使用して{N}にドロワーを作成する方法をデモンストレーションしています。あなたのプロジェクトに役立つことを願っています。
ビルドしようとした後、またはtypescript intellisenseの中でこのエラーが発生しましたか?インテリセンスのエラー "名前を見つけることができませんアンドロイド" "あなたはそれを無視する必要があります - あなたのプロジェクトは問題なく構築され、あなたはAndroidとiOSからのネイティブAPIにアクセスします。 –
コンソールに 'tsc'コマンドを入力すると、そのエラーが発生します。 –
あなたは私たちといくつかの情報を共有してください...あなたが実行しているコマンドやビルドしようとしているコードのいくつかなど –