小编sr.*_*zad的帖子

如何在Google Map Api V2 Android中搜索?

我正在开发Android应用程序并使用GoogleMaps API v2.此应用程序到目前为止工作,但我想在地图中搜索路径:

截图:

GoogleMaps截图

我的代码:

Position_mark = new LatLng(35.7008, 51.437);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(Position_mark, 15));
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
map.setOnMapClickListener(this);
map.setOnMapLongClickListener(this);
map.setOnMarkerDragListener(this);
Run Code Online (Sandbox Code Playgroud)

...

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    //Used to put dark icons on light action bar

    mGoItem = menu.add(0, Delete_ITEM_ID, 0, null);
    mGoItem.setIcon(R.drawable.ic_launcher)
           .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    SearchView searchView = 
        new SearchView(getSupportActionBar().getThemedContext());
    searchView.setQueryHint("Search for Places…");
    searchView.setIconified(false);

    menu.add("Search")
        .setIcon(R.drawable.abs__ic_search)
        .setActionView(searchView)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String newText) {
            return true;
        }

        /**
         * Called when the query text is changed by the user.
         * …
Run Code Online (Sandbox Code Playgroud)

android google-maps geolocation google-maps-markers google-maps-api-2

14
推荐指数
1
解决办法
3万
查看次数

如何从Android的USSD代码获取响应?

我编写了一个使用ussd代码的应用程序.我想发送一个ussd的请求,但我不知道如何获取数据并将其保存在String中.

示例代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button btn = (Button) findViewById(R.id.button1);

    btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            String encodedHash = Uri.encode("#");
            String ussd = "*141*1" + encodedHash;
            startActivityForResult(new Intent("android.intent.action.CALL",
                    Uri.parse("tel:" + ussd)), 1);

        }
    });
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);

    Toast.makeText(getApplicationContext(),
            "USSD: " + requestCode + "  " + resultCode + " ", 1).show(); …
Run Code Online (Sandbox Code Playgroud)

service android ussd

13
推荐指数
1
解决办法
2万
查看次数

如何在Android中使用Wifi获取位置?

我希望通过Wifi获取位置并在谷歌地图中工作,这对我不起作用,但Gps没问题,也没问题.

我的代码:

locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

if (locationManager != null) {
    boolean gpsIsEnabled = locationManager
            .isProviderEnabled(LocationManager.GPS_PROVIDER);
    boolean networkIsEnabled = locationManager
            .isProviderEnabled(LocationManager.NETWORK_PROVIDER);

    if (gpsIsEnabled) {
        locationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER, 5000L, 10F,
                (android.location.LocationListener) this);
    } else if (networkIsEnabled) {
        locationManager.requestLocationUpdates(
                LocationManager.NETWORK_PROVIDER, 5000L, 10F,
                (android.location.LocationListener) this);
    } else {
        // Show an error dialog that GPS is disabled...
    }
} else {
    // Show some generic error dialog because something must have gone
    // wrong with location manager.
}
Run Code Online (Sandbox Code Playgroud)

AndroidManifest:

<uses-library android:name="com.google.android.maps" />

<meta-data
    android:name="com.google.android.maps.v2.API_KEY" …
Run Code Online (Sandbox Code Playgroud)

java android android-location location-provider

6
推荐指数
2
解决办法
2万
查看次数

如何理解电话在Android中很忙?

我编写了使用AlarmManager的应用程序,它的工作非常好但是当用户使用电话说话时,音乐在alarmManager中播放,因此对用户来说不好.

如何在电话忙时禁用AlarmManager

谢谢...

java android broadcastreceiver alarmmanager

2
推荐指数
1
解决办法
868
查看次数

如何在Android中将Imageview放在Listview下面?

我有我的活动布局,这个布局包含很多小部件.在我从Listview中的webservice加载的活动数据中.当listview被改编并填写所有数据时.imagview是看不见的但我想在数据加载时将Listview显示在Listview下面.

我在activity_main.xml中的代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rel_index"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f8f8f8"
    tools:context=".MainActivity" >

    <EditText
        android:id="@+id/edt_search"
        android:layout_width="fill_parent"
        android:layout_height="40sp"
        android:layout_marginLeft="10sp"
        android:layout_marginRight="10sp"
        android:layout_marginTop="115sp"
        android:background="@drawable/round_corener_edittext"
        android:drawableLeft="@drawable/center"
        android:hint="@string/search"
        android:paddingLeft="5sp"
        android:paddingRight="5sp"
        android:textColor="#44e1f4" />

    <RelativeLayout
        android:id="@+id/rel_top"
        android:layout_width="fill_parent"
        android:layout_height="135sp"
        android:layout_marginBottom="25sp"
        android:background="@drawable/header" >

        <ImageView
            android:id="@+id/img_logo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_margin="10sp"
            android:background="@drawable/digi_logo"
            android:visibility="gone" />

        <View
            android:id="@+id/line"
            android:layout_width="fill_parent"
            android:layout_height="1dip"
            android:layout_below="@+id/img_logo"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="20sp"
            android:layout_marginRight="20sp"
            android:background="#2391a2"
            android:visibility="gone" />

        <TextView
            android:id="@+id/txt_app"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/line"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="10sp"
            android:layout_marginTop="5sp"
            android:text="@string/txt_name"
            android:textColor="#1e7c95"
            android:textSize="14sp"
            android:visibility="gone" />
    </RelativeLayout>

    <ListView
        android:id="@+id/lst_data"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/rel_top"
        android:layout_marginBottom="10sp"
        android:clipToPadding="false" />



    <ImageView
        android:id="@+id/img_offer"
        android:layout_width="fill_parent"
        android:layout_height="70sp"
        android:layout_below="@+id/lst_data"
        android:adjustViewBounds="true" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-listview

2
推荐指数
1
解决办法
1759
查看次数