我正在使用片段和..
我的代码中遇到了一个我无法找到的问题.
logcat指向这段代码,在我的一个片段中:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.activity_main, container, false);
}
Run Code Online (Sandbox Code Playgroud)
我的主要类(FragmentActivity):
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
public class Fragments extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragments);
MainActivity fragment = new MainActivity();
FragmentTransaction transaction = getSupportFragmentManager()
.beginTransaction();
transaction.add(R.id.fragment_place, fragment);
transaction.commit();
}
public void onSelectFragment(View view) {
Fragment newFragment;
if (view == findViewById(R.id.add)) {
newFragment = new Add();
} else if (view == …Run Code Online (Sandbox Code Playgroud) android class android-fragments layout-inflater android-fragmentactivity
我必须通过坐标获得一个地址,但它不起作用并输出"无法获取地址":
public String GetAddress(String lat, String lon)
{
Geocoder geocoder = new Geocoder(this, Locale.ENGLISH);
String ret = "";
try {
List<Address> addresses = geocoder.getFromLocation(Double.parseDouble(lat), Double.parseDouble(lon), 1);
if(addresses != null) {
Address returnedAddress = addresses.get(0);
StringBuilder strReturnedAddress = new StringBuilder("");
for(int i=0; i<returnedAddress.getMaxAddressLineIndex(); i++) {
strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\n");
}
ret = strReturnedAddress.toString();
ret=ret.substring(0, ret.length() - 1);
}
else{
ret = "Unknown Address";
}
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ret = "Couldn't get Address";
}
return ret;
} …Run Code Online (Sandbox Code Playgroud) 我试图编写一些使用Google Maps API的应用程序.地图显示在主要活动中.
在某些手机上,包括模拟器,应用程序在启动后立即崩溃.它唯一使用的手机是我的Galaxy S1,它运行CM10.1(4.2.2).
它崩溃了我的HTC DESIRE HD(也是4.2.2)
MainActivity.java:
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.Toast;
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.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class MainActivity extends Activity {
public void ToastLoadShout(String msg){Toast.makeText(this, msg, Toast.LENGTH_LONG).show();}
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
static final LatLng KIEL = new LatLng(53.551, 9.993);
static final LatLng …Run Code Online (Sandbox Code Playgroud) 我试图覆盖半径,在地图上说5公里.我有中间的坐标.
我需要一种方法来计算并给出该圆上的点的坐标.
说明:

(我需要它从我的服务器获取__Km半径内的坐标点,如果有更好的方法,请分享.ty!)
我会检查坐标是否在圆圈内是否是这样的:
(lan,lon)是一个观点.
if ((lat<x1 && lat>x2) && (lon<y1 && lon>y2))
then the point is inside the circle.
Run Code Online (Sandbox Code Playgroud)
但那么问题就是在世界某些地方它不起作用......
我糊涂了.我该怎么做雷达?
(Android应用程序)
谢谢!
就像标题所说,由于某些我不理解的原因,我在我的应用程序中创建的每个活动都显示为手机应用程序菜单上的应用程序的图标.
有人可以帮我解决这个奇怪的问题吗?
如果你需要一些代码只需要它(我不知道哪些代码与这些东西有关).
谢谢!