この質問を対象とするスレッドがたくさんあることは知っていますが、解決策は私を助けないでしょう。私はスタート画面上の私のボタンがテントの中にテキストフィールドからのデータを置き、その意図を持って新しい活動を開始し、私のメインの活動の方法を使用したいAndroidボタンonClickは反応しません
:
I`veは、次のような問題を得ました。同じコードがAndroidスタジオでどのように機能していたのですが、Eclipseではそれができませんでした。エラーか何かは、LogCatは私に与えていない場合にのみ、この:
6月20日14:08:39.003:D/AudioFlinger(1199):ミキサー(0xb44c0000)スロットル終了:スロットル時間を(68)
I`veはこのように私のacitivity_main.xmlファイルのボタンを定義した:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="com.example.jule.bachelorapp.MainActivity">
<EditText
android:id="@+id/edit_standort"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/edit_standort"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/edit_zeit"/>
<Button
android:id="@+id/button_sendData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_sendData"
android:onClick="viewAdress"
/>
</LinearLayout>
マイMainActivity.javaファイルは次のようになります。
package com.example.bachelorapp;
import com.example.bachelorapp.R;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void viewAdress(View view){
EditText editText = (EditText) findViewById(R.id.edit_standort);
String adresse = editText.getText().toString();
Uri mapIntentUri = Uri.parse("geo:0,0?q="+ Uri.encode(adresse));
Intent mapIntent = new Intent(Intent.ACTION_VIEW, mapIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
if(mapIntent.resolveActivity(getPackageManager()) != null){
startActivity(mapIntent);
}
}
}
私はボタンを押してから開きたいAcitivty私MapActivity.javaです:誰もが知ってい
package com.example.bachelorapp;
import android.support.v4.app.FragmentActivity;
import android.annotation.SuppressLint;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapActivity extends FragmentActivity implements OnMapReadyCallback {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
MapFragment mapFragment = (MapFragment) getFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap map) {
LatLng adress = new LatLng(48.362206, 10.908704);
map.addMarker(new MarkerOptions()
.position(adress)
.title("Zuhause"));
}
}
、アンドロイドとの理由ボタン:onClickのは反応しdoesntの?
私はあなたのEditTextから活動にテキストを渡したい場合は、あなたがこのような何かをするだろう
挨拶 ジュール
このためmapIntent.setPackage( "com.google.android.apps.maps")のものであってもよいです。 Googleマップのための意図構造が与えられている https://developers.google.com/maps/documentation/android-api/intents#intent-anforderungen と:あなたはこのチュートリアルでは、独自の活動 –