我正在尝试在Play商店中进行相同的标签布局.我必须使用来自androidhive的片段和viewpager来显示标签布局.但是,我无法在其上实现谷歌地图v2.我已经在互联网上搜索了好几个小时,但我找不到如何做的教程.有人可以告诉我怎么样?
我对Android Studio有一个奇怪的问题.以下是我的类文件在Android Studio上的样子
这就是文本编辑器的样子.
任何想法为什么会发生?我尝试关闭然后重新导入项目,使缓存无效并重新启动,清理项目,构建项目,删除.idea文件夹和.iml文件.在AS中打开时,我的所有文件都被破坏,但在文本编辑器上看起来很好.
我想将图像存储在我的数据库中.另外,我想检查图像和标题是否已存在于数据库中.如果是这样,它将不会将它们添加到数据库中.这是我的班级.
景点
public class Attractions extends ListActivity {
DataBaseHandler db = new DataBaseHandler(this);
ArrayList<Contact> imageArry = new ArrayList<Contact>();
List<Contact> contacts;
ContactImageAdapter adapter;
int ctr, loaded;
int [] landmarkImages={R.drawable.oblation,R.drawable.eastwood,R.drawable.ecopark,R.drawable.circle};
String []landmarkDetails = { "Oblation", "Eastwood", "Ecopark", "QC Circle"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_attractions);
ctr = db.checkContact(landmarkDetails[loaded]);
// get image from drawable
/**
* CRUD Operations
* */
// Inserting Contacts
Log.d("Insert: ", "Inserting ..");
for(loaded=0; loaded <landmarkDetails.length;loaded++){
Bitmap image …Run Code Online (Sandbox Code Playgroud) 这是关于我的应用程序的一些细节.我有一个标签布局使用Fragments和a ViewPager.在第三个标签上,我有一个Google Map V2.现在,只要应用程序的用户位于某个地标,他就可以在Facebook上分享有关该地标的详细信息.我已成功创建地图,但有关地标的详细信息尚未完成.现在关于facebook的"分享"功能,我已经按照facebook开发者的步骤进行了操作.当我运行应用程序时,我收到错误:
10-17 14:19:06.856: E/AndroidRuntime(2180): java.lang.NullPointerException: Argument 'applicationId' cannot be null
Run Code Online (Sandbox Code Playgroud)
在搜索之后,我发现我需要将应用程序ID放在manifest.xml.
这是我的元数据:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="the key from google api console"
/>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="the key from fb devs"
/>
Run Code Online (Sandbox Code Playgroud)
但是,我仍然得到错误:
10-17 14:44:03.076: E/AndroidRuntime(2240): java.lang.NullPointerException: Argument 'applicationId' cannot be null
Run Code Online (Sandbox Code Playgroud)
整个Facebook共享对话框位于一个Fragment.
这里是:
TabFour.java
public class TabFour extends Fragment {
private UiLifecycleHelper uiHelper;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_tab_four, container, false); …Run Code Online (Sandbox Code Playgroud) 我的地图上有一个圆圈.现在我想检测用户(或我)是否在圈内.
Circle circle = map.addCircle(new CircleOptions()
.center(new LatLng(14.635594, 121.032962))
.radius(55)
.strokeColor(Color.RED)
);
Run Code Online (Sandbox Code Playgroud)
我有这个代码:
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationListener ll = new myLocationListener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,ll);
Location.distanceBetween( pLat,pLong,
circle.getCenter().latitude, circle.getCenter().longitude, distance);
if( distance[0] > circle.getRadius() ){
Toast.makeText(getBaseContext(), "Outside", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getBaseContext(), "Inside", Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)
在myLocationListener上我有这个:
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
pLong = location.getLongitude();
pLat = location.getLatitude();
}
Run Code Online (Sandbox Code Playgroud)
如果我的参数里面distanceBetween是标记的坐标,它可以正常工作,但是,即使我的位置在半径内,吐司也显示在外面.

任何想法如何正确地做到这一点?请帮忙.谢谢!
编辑
我发现了一些奇怪的事
在图片上,你可以看到我上面有一个textView,它有5个数字(圆纬度,圆经度,索引0处的距离,索引1处的距离,距离2).distance是一个浮点数组,用于存储圆心和用户位置之间的距离.我将半径设置为100,我认为单位是米,但是,如您所见,distance数组中的值为:1.334880E7,-81.25308990478516, …
我只是想问一下是否有办法改变事件的门槛touchmove?在我的PhoneGap应用程序中,将出现一个图像.如果touchstart触发,则会出现另一个图像.如果touchend或被touchmove触发,所有图像必须消失.这是我的代码:
$('.greenApple').on('touchend', function (e){
$('body').find('.active').removeClass('active');
$('body').find('.greenApple').addClass('hidden');
flag = true;
return;
});
$('.greenApple').on('touchmove', function (e){
$('body').find('.active').removeClass('active');
$('body').find('.greenApple').addClass('hidden');
flag = true;
return;
Run Code Online (Sandbox Code Playgroud)
然而,被认为是a的像素数量的阈值touchmove太小.通常,只要我按下图像(不释放它,touchend没有被触发),图像就会因为touchmove事件被触发而消失.有没有办法改变被认为是移动的像素数touchmove?还是有其他解决方法?
谢谢.
我在片段中的共享对话框中有以下代码:
TabFour.java
public class TabFour extends Fragment {
private UiLifecycleHelper uiHelper;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_tab_four, container, false);
return rootView;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(getActivity(), callback);
uiHelper.onCreate(savedInstanceState);
OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
action.setProperty("book", "https://example.com/book/Snow-Crash.html");
@SuppressWarnings("deprecation")
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "books.reads", "book")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data, new FacebookDialog.Callback() {
@Override …Run Code Online (Sandbox Code Playgroud) 我想在我的VideoView中添加一个mediaController.我正在尝试按照本网站的教程.
但是,我的课程中出现了错误.
MediaController mediaController = new MediaController(this);
Run Code Online (Sandbox Code Playgroud)
错误说,
MediaController (Context, Token) in MediaController cannot be applied to (MainActivity)
Token参数是什么?自从我使用原生Android编码以来我已经有一段时间了,我想我错过了一些必要的细节和变化.
编辑 我正在寻找一个不同的教程,链接中的一个,是在Android Studio中制作的.我的错.
我的课
public class MainActivity extends ActionBarActivity {
public VideoView videoOne;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoOne = (VideoView) findViewById(R.id.videoView);
videoOne.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video1));
videoOne.start();
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoOne);
videoOne.setMediaController(mediaController);
videoOne.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
Log.i("Video Duration", "Duration = " + videoOne.getDuration());
} …Run Code Online (Sandbox Code Playgroud) eclipse android mediacontroller android-studio android-videoview
问题可能是愚蠢但我会问它,例如我有3个活动,活动1,2,3.
活动1,我点击一个按钮,转到活动2活动2,我点击一个按钮,转到活动3.活动3,我点击后退按钮,我希望它回到活动1.任何想法怎么做?对不起Android新手.谢谢!
我正在修改toucheventsjs。我在 eclipse 的 logcat 中遇到了这个错误。
document.getElementById("squareBracket").
addEventListener("touchmove", touchHandler, false);
document.getElementById("squareBracket").
addEventListener("touchend", touchHandler, false);
function touchHandler(e) {
if (e.type == "touchstart") {
alert("You touched the screen!");
} else if (e.type == "touchmove") {
// alert(e.changedTouches[0].pageX);
// alert(e.changedTouches[0].pageY);
} else if (e.type == "touchend" || e.type == "touchcancel") {
alert('X :' + e.targetTouches[0].pageX);
alert('Y :' + e.targetTouches[0].pageY);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我删除的注释if中touchmove,坐标弹出。但是,如果被注释了,我的logcat中就会出现错误。
我遇到了一个不同的错误.我尝试做Facebook Share Dialog但是我在logcat中遇到了这个错误.
10-17 15:44:39.026: E/AndroidRuntime(2534): com.facebook.FacebookException: Unable to create Intent; this likely means the Facebook app is not installed.
Run Code Online (Sandbox Code Playgroud)
我不知道这是什么意思.我试图搜索它,但没有类似的实例.这是我的代码.
TabFour.java
public class TabFour extends Fragment {
private UiLifecycleHelper uiHelper;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_tab_four, container, false);
return rootView;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(getActivity(), callback);
uiHelper.onCreate(savedInstanceState);
OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
action.setProperty("book", "https://example.com/book/Snow-Crash.html");
@SuppressWarnings("deprecation")
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "books.reads", "book")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
} …Run Code Online (Sandbox Code Playgroud) android ×9
cordova ×2
facebook ×2
google-maps ×2
java ×2
javascript ×2
jquery ×2
share ×2
back-button ×1
bitmap ×1
eclipse ×1
sqlite ×1
touchstart ×1