2017-06-11 7 views
0

私のAndroidアプリケーションのInfoWindowにこの問題があります。このコードを実行すると、setTextメソッドの実行中にアプリケーションがクラッシュします。InfoWindowのsetTextでアプリケーションがクラッシュする

@Override 
public View getInfoWindow(Marker marker) { 

    LayoutInflater inflater = getLayoutInflater(); 
    View view = inflater.inflate(R.layout.lkonty, null); 

    TextView txtName= (TextView) findViewById(R.id.txtName); 
    txtName.setText(marker.getTitle()); 
    return view; 

私は、このコード行を追加して解決策を見つけない:

setContentView(R.layout.lkonty); 

アプリがクラッシュしなくなりましたが、今情報ウィンドウが画面全体を埋め、私はそれを変更する方法がわかりません。

答えて

0

この

View v = LayoutInflater.from(parent.getContext()) 
.inflate(R.layout.lkonty,parent,false); 


TextView txtName= (TextView) view.findViewById(R.id.txtName); 

txtName.setText(marker.getTitle()); 
をお試しください
0

テキストビューtxtNameがnullであるため、アプリケーションがクラッシュします。 txtNameviewで膨らんでいるはずです。 それは、これを好きになるでしょう:

@Override 
public View getInfoWindow(Marker marker) { 

    LayoutInflater inflater = getLayoutInflater(); 
    View view = inflater.inflate(R.layout.lkonty, null); 

    TextView txtName= (TextView) view.findViewById(R.id.txtName); 
    txtName.setText(marker.getTitle()); 
    return view; 
} 
0

私はあなたのTextViewを結合しながら、あなたにビューを使用することを忘れてしまったと思います。

TextView txtName= (TextView) view.findViewById(R.id.txtName); 

あなたはインフレータの使用中ビューを使用する必要があります。

関連する問題