0

カスタムタイルのマップがあり、カスタムマップのカラーコードを説明するオプションの凡例をサイトに追加する必要があります。

私は今、メニューを介して画像を表示するトーストをトリガーすることによって、私が望むことを達成しようとしました。しかし、トーストは最大3.5秒しか表示されないことを知りましたが、タップされるまでマップ上にオーバーレイされたままの何かが必要になります。したがって、背景の地図が移動されても消えることはありません。

編集:これがポップアップを使用する私の試みです。しかし、メニューをクリックすると、アプリは「残念ながら停止します」。

これが私のメニューです:

public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    //..
        case R.id.legenda:
            showLegenda();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }

そして、これが私のポップアップが今どのように見えるかです。

private void showLegenda() {
    // TODO Add popup here
 /*   LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.toastlegenda,
                                   (ViewGroup) findViewById(R.id.relativeLayout1));

    Toast toast = new Toast(this);
    toast.setView(view);
    toast.show();*/

    LayoutInflater inflater = (LayoutInflater)
               this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            PopupWindow pw = new PopupWindow(
               inflater.inflate(R.layout.toastlegenda, null, false), 
               100, 
               100, 
               true);
            // The following line raises the error:
            pw.showAtLocation(this.findViewById(R.id.mapview), Gravity.CENTER, 0, 0);

}

これが私のR.id.mapviewが由来するmap_layout.xmlです:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
<org.osmdroid.views.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>
</LinearLayout>

mapviewをポップアップのルートコンテナとして使用することはできませんか?マップビューはタブビューの一部です。誰かが私にここでエラーを引き起こすもののヒントを与えることができれば素晴らしいでしょう。

これがtoastlegenda.xmlです(トーストを使って議事を行うという以前の試みに由来します)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"  
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:id="@+id/relativeLayout1"
  android:background="@android:color/transparent">

<TextView
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:id="@+id/textView1" android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:text="Test"
    android:gravity="center"
    android:textColor="@android:color/black">
</TextView>

<ImageView
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:src="@drawable/dcmr_legenda_bl"
    android:layout_below="@+id/textView1"
    android:layout_margin="5dip"
    android:id="@+id/imageView1">
</ImageView>

<TextView
    android:id="@+id/textView2"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:text="Test 1,2, 1,2..."
    android:gravity="center"
    android:layout_below="@+id/imageView1"
    android:textColor="@android:color/black">
</TextView>

</RelativeLayout>

と全体のエラー:

E/AndroidRuntime(15404): FATAL EXCEPTION: main
E/AndroidRuntime(15404): java.lang.NullPointerException
E/AndroidRuntime(15404):    at android.widget.PopupWindow.showAtLocation(PopupWindow.java:809)
E/AndroidRuntime(15404):    at nl.sense.demo.MapActivity.showLegenda(MapActivity.java:156)
E/AndroidRuntime(15404):    at nl.sense.demo.MapActivity.onOptionsItemSelected(MapActivity.java:122)
E/AndroidRuntime(15404):    at android.app.Activity.onMenuItemSelected(Activity.java:2502)
E/AndroidRuntime(15404):    at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:969)
E/AndroidRuntime(15404):    at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
E/AndroidRuntime(15404):    at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
E/AndroidRuntime(15404):    at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
E/AndroidRuntime(15404):    at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:468)
E/AndroidRuntime(15404):    at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:126)
E/AndroidRuntime(15404):    at android.view.View$PerformClick.run(View.java:14263)
E/AndroidRuntime(15404):    at android.os.Handler.handleCallback(Handler.java:605)
E/AndroidRuntime(15404):    at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(15404):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(15404):    at android.app.ActivityThread.main(ActivityThread.java:4441)
E/AndroidRuntime(15404):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(15404):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(15404):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(15404):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(15404):    at dalvik.system.NativeStart.main(Native Method)
4

0 に答える 0