我有以下JSON文本.如何可以解析它来获得pageName,pagePic,post_id,等?
{
"pageInfo": {
"pageName": "abc",
"pagePic": "http://example.com/content.jpg"
},
"posts": [
{
"post_id": "123456789012_123456789012",
"actor_id": "1234567890",
"picOfPersonWhoPosted": "http://example.com/photo.jpg",
"nameOfPersonWhoPosted": "Jane Doe",
"message": "Sounds cool. Can't wait to see it!",
"likesCount": "2",
"comments": [],
"timeOfPost": "1234567890"
}
]
}
Run Code Online (Sandbox Code Playgroud) 我在textview中显示文本,看起来太长,无法放入一个屏幕.我需要让我的TextView可滚动.我怎样才能做到这一点?
这是代码:
final TextView tv = new TextView(this);
tv.setBackgroundResource(R.drawable.splash);
tv.setTypeface(face);
tv.setTextSize(18);
tv.setTextColor(R.color.BROWN);
tv.setGravity(Gravity.CENTER_VERTICAL| Gravity.CENTER_HORIZONTAL);
tv.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent e) {
Random r = new Random();
int i = r.nextInt(101);
if (e.getAction() == e.ACTION_DOWN) {
tv.setText(tips[i]);
tv.setBackgroundResource(R.drawable.inner);
}
return true;
}
});
setContentView(tv);
Run Code Online (Sandbox Code Playgroud) 我想存储一个时间值,需要检索和编辑它.我SharedPreferences该怎么用呢?
我无法弄清楚为什么我无法在我的VideoView中播放视频.所有我收到的消息是:
无法播放视频:对不起,此视频无法播放.
我也为我的模拟器创建了一张SD卡.我是否需要将SD卡放入SDK中的特定文件夹中?请评论.
这是布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/LinearLayout01"
android:layout_height="fill_parent"
android:paddingLeft="2px"
android:paddingRight="2px"
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="2px"
android:paddingBottom="2px"
android:layout_width="fill_parent"
android:orientation="vertical">
<VideoView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/VideoView" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是代码:
package com.examples.videoviewdemo;
import android.app.Activity;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class VideoViewDemo extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView videoView = (VideoView)findViewById(R.id.VideoView);
//MediaController mediaController = new MediaController(this);
// mediaController.setAnchorView(videoView);
//videoView.setMediaController(mediaController);
videoView.setVideoPath("/sdcard/blonde_secretary.3gp");
videoView.start();
}
}
Run Code Online (Sandbox Code Playgroud)
等待回复......
我很想知道使用Phonegap与使用Android相比是否存在任何缺点或限制.我们还能用其他平台完成哪些无法实现的目标?
为什么要专门选择Phonegap而不是Android(除了预算或跨平台兼容性),反之亦然?我正在寻找有理由的明确场景.
当用户在屏幕上滑动手指时,如何使页面滑动?任何示例代码?
我只需要在我的android g-phone的主屏幕上感受到它的感觉.屏幕随着手指移动而移动(还包括弹性效果).
到目前为止,我们已经在android中开发了在运行时创建数据库的应用 我们想知道如何在我们的Android应用程序中访问预先构建的或现有的数据库/ sqlite文件?请提供详细信息
什么是队列在计算机科学中的实际应用.我们在哪里使用它们?为什么?我听说我们在视频游戏和计算机模拟程序中使用它们,是真的吗?为什么?除了这两个领域,队列作为数据结构的其他实际应用是什么?
现在我想要的只是一个应用程序,只需在启动时从相机拍摄照片.没有布局,没有相机预览......没有,只是一个简单的应用程序图标来启动应用程序.一旦启动,相机应该拍照.
这是预览图像,我不想在我的应用程序中显示.我只是想让我的应用程序点击图片中包围的拍照按钮:

拍完照片后,我需要将照片保存在照片库中.
有人能指导我吗?谢谢
这是我在仿真器和设备上尝试过的一些代码.
import java.io.IOException;
import android.app.Activity;
import android.hardware.Camera;
import android.hardware.Camera.PictureCallback;
import android.hardware.Camera.ShutterCallback;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
public class Main extends Activity implements SurfaceHolder.Callback{
private Camera camera;
private ImageButton cameraClick;
private SurfaceHolder mHolder;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SurfaceView surfaceView = (SurfaceView)findViewById(R.id.surfaceView1);
mHolder = surfaceView.getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
cameraClick = (ImageButton) findViewById(R.id.cameraClick);
cameraClick.setOnClickListener( …Run Code Online (Sandbox Code Playgroud)