小编tej*_*jas的帖子

如何在按下按钮时阻止活动加载两次

如果我在第一次点击后立即按两次按钮,我试图阻止活动加载两次.

我有一个活动,点击按钮加载,比方说

 myButton.setOnClickListener(new View.OnClickListener() {
      public void onClick(View view) {
       //Load another activity
    }
});
Run Code Online (Sandbox Code Playgroud)

现在因为要加载的活动具有网络调用,所以加载(MVC)需要一些时间.我确实显示了加载视图,但如果我在此之前按下按钮两次,我可以看到活动被加载两次.

有谁知道如何防止这种情况?

android onclick button android-activity

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

创建Galaxy S4模拟器

我试图在Galaxy S4上专门运行我的应用程序.但我没有实时设备.所以,我正在尝试为Galaxy S4创建模拟器.我有一个普通的Core I3系统,带有4GB RAM.它没有任何显卡.

我正在寻找将三星Galaxy S4插件安装到我的sdk的方法.但我没有得到它.

我提到了这些链接,

Android Galaxy S4模拟器无法打开

如何使用模拟器在Galaxy S4配置中测试Android应用程序?

http://developer.samsung.com/android/technical-docs/Using-Samsung-Emulators-for-Android-Application-Development

http://developer.samsung.com/board/list.do?ctgy1=1&ctgy2=1&menu=EN01010301&srchYn=Y&pageIndex=1&pageSize=10&search=

但是,我无法通过这些获得任何结果.

然后我为Galaxy S4引用了这个替代方案,即为Xperia Z安装Sony附加组件,它具有与S4相同的配置.我能够创建一个Xperia Z avd.我也选中了"使用主机GPU"选项.但是,屏幕看起来仍然是全黑的.

http://developer.sonymobile.com/knowledge-base/sony-add-on-sdk/install-the-sony-add-on-sdk/

所以任何机构都可以告诉我如何安装S4添加,以便我可以为它创建一个模拟器.

更新:

RAM已分配:256MB
HeapSize:64
我已将屏幕尺寸修改为4.0英寸以适应我的系统.

在此输入图像描述

android android-virtual-device android-emulator samsung-mobile

12
推荐指数
4
解决办法
7万
查看次数

在地图中显示当前位置时获取纬度和经度0.0

我使用以下代码来获取我当前的位置.但我面临的问题是,纬度和经度总是返回0.0.我已打开手机中的GPS设置并设置所有权限.但我仍然面对这个问题.

locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

customLocationListener = new CustomLocationListener();

locationManager.requestLocationUpdates(

        LocationManager.GPS_PROVIDER,

        0,

        0,

        customLocationListener);

class CustomLocationListener implements LocationListener{ ............

      public void onLocationChanged(Location argLocation) { 

         if(location != null) {     

        int latitude=(int)(argLocation.getLatitude()*1E6);   

        int longitude=(int)(argLocation.getLongitude()*1E6);


              }
       } ........ }
Run Code Online (Sandbox Code Playgroud)

你们中的任何人都知道为什么吗?

注意:我的活动扩展了MapActivity而不是Location Listener

android google-maps map geolocation userlocation

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

绘制虚线(....)轨迹而不是线(________)

现在,下面是我在地图中绘制地理位置之间路径的代码.这完全没问题.我想要实现的不是画一条线,而是用iPhone中的点(.)显示这条路径.我希望它像这个gp1 ......... gp2而不是像gp1_ _ __ _ _gp2 一样画一条直线.

我已经尝试了几乎所有的选择,但仍然没有成功,任何人都可以帮我解决这个问题?

private void drawPath(List geoPoints, int color) {
    List overlays = objMapView.getOverlays();
    int loopcount = geoPoints.size() - 1;
    for (int i = 0; i < loopcount; i++) {
        GeoPoint p1 = (GeoPoint) geoPoints.get(i);
        GeoPoint p2 = (GeoPoint) geoPoints.get(i + 1);
        MyPathOverLay p = null;
        /**** Marking the start and end of the trailpath ****/
        if (i == 0) {
            Bitmap bmp = BitmapFactory.decodeResource(this.getResources(),R.drawable.greenflag);
            p = new MyPathOverLay(p1, p2, 0xFFFF0000, true, false, bmp); …
Run Code Online (Sandbox Code Playgroud)

android google-maps bitmap map android-canvas

5
推荐指数
1
解决办法
8660
查看次数

如何在Web视图中加载存储在SD卡内的html文件

我在/mnt/sdcard/packagename/files/something.html路径中有一个html文件.现在我想将此文件加载到webview中.

当我为此浏览时,我听到了有关内容提供商的一些信息,但仍然没有清楚地知道如何做到这一点.

有答案吗?

提前致谢,

Tejaswi Marakini

html android android-webview

4
推荐指数
1
解决办法
9838
查看次数

动态更改图像视图背景

我的布局中有一组10个图像视图.我已经给它们顺序id了

android:id="@+id/pb1"

android:id="@+id/pb2"
Run Code Online (Sandbox Code Playgroud)

现在我想动态更改背景.

    int totalPoi = listOfPOI.size();
    int currentPoi = (j/totalPoi)*10;
    for (i=1;i<=currentPoi;i++) {
          imageview.setBackgroundResource(R.drawable.progressgreen);
}
Run Code Online (Sandbox Code Playgroud)

现在在for循环中我想动态设置图像视图背景.i,e如果currentpoi值为3,则应更改3个图像视图的背景.for循环迭代的次数应该改变许多图像视图的背景.希望现在问题很明确.

注意:我只有1个图像progressgreen需要设置为10个图像视图

android imageview

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

在应用程序中评估Android应用程序

我正在尝试使用我可以允许用户从我的应用程序评估我的应用程序的功能.我并不专注于通常的Android市场指向然后这样做.相反,我希望我的应用程序有直接评级系统.

我很确定这可以在iPhone上完成,但任何人都知道在android中做什么?

android rating

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

有时候列表视图的viewTypeCount <1错误

我正进入(状态

IllegalArgumentException:不能有viewTypeCount <1

对于我的列表视图有时候.我知道这是为了list.size().但这并不经常发生,只有一些我得到这个错误和应用程序崩溃.我还没有得到解决方案,有没有人知道这个?

更新:这是我得到的

10-17 05:34:49.103: ERROR/AndroidRuntime(1683): FATAL EXCEPTION: main
10-17 05:34:49.103: ERROR/AndroidRuntime(1683): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.racontrs/com.racontrs.Racontours.City}: java.lang.IllegalArgumentException: Can't have a viewTypeCount < 1
10-17 05:34:49.103: ERROR/AndroidRuntime(1683):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-17 05:34:49.103: ERROR/AndroidRuntime(1683):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-17 05:34:49.103: ERROR/AndroidRuntime(1683):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-17 05:34:49.103: ERROR/AndroidRuntime(1683):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-17 05:34:49.103: ERROR/AndroidRuntime(1683):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-17 05:34:49.103: ERROR/AndroidRuntime(1683):     at android.os.Looper.loop(Looper.java:130)
10-17 05:34:49.103: ERROR/AndroidRuntime(1683):     at android.app.ActivityThread.main(ActivityThread.java:3683)
10-17 05:34:49.103: ERROR/AndroidRuntime(1683):     at java.lang.reflect.Method.invokeNative(Native Method)
10-17 05:34:49.103: ERROR/AndroidRuntime(1683):     at java.lang.reflect.Method.invoke(Method.java:507)
10-17 05:34:49.103: ERROR/AndroidRuntime(1683):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) …
Run Code Online (Sandbox Code Playgroud)

android listview illegalargumentexception

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

单击图像按钮时,Selector.xml不起作用

当我点击它时,我使用以下选择器来更改图像按钮的图像.但这在大多数时候都不起作用.只有几个按钮才有效.不知道这里的原因是什么

 mapselector.xml
 <?xml version="1.0" encoding="utf-8"?>

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <!-- Button Pressed -->
        <item android:state_focused="true" android:state_pressed="true" 
    android:drawable="@drawable/mapiconover"/>
</selector>
Run Code Online (Sandbox Code Playgroud)

在按钮中,

我是这样做的,

  <ImageButton 
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:id="@+id/btnMap" android:layout_centerInParent="true"  android:src="@drawable/mapselector"
    android:background="@drawable/map" android:scaleType="fitXY"
    android:layout_alignParentBottom="true">
</ImageButton>
Run Code Online (Sandbox Code Playgroud)

但是当我点击时,静止图像并没有改变.

对此有何猜测?

android css-selectors imagebutton

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

横向模式下视频视图不是全屏

我正在使用用xml设计的视频视图.此视频在纵向模式下全屏显示,但当它转为横向模式时,它会保持对齐状态,宽度和高度都会被包裹而不是全屏.

我提到了这些,但仍然没有解决方案.

全屏VideoView不是居中的

Android全屏视频观看

任何人都知道答案吗?

更新:这是我的xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">


<VideoView android:id="@+id/youtubewebView"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:layout_alignParentLeft="true" android:layout_alignParentTop="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true" android:layout_gravity="fill" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

更新2:

public class VideoStreamingActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final VideoView videoView = (VideoView)findViewById(R.id.your_video_view);
    String videoUrl = "http://www.pocketjourney.com/downloads/pj/video/famous.3gp";
    try {
    Uri uri = Uri.parse(videoUrl);
    videoView.setVideoURI(uri);
    videoView.setMediaController(new MediaController(this));
    videoView.requestFocus();
    //videoView.start();
    videoView.setOnErrorListener(new OnErrorListener() {

        @Override
        public boolean onError(MediaPlayer arg0, int arg1, int …
Run Code Online (Sandbox Code Playgroud)

xml android landscape

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

无法在未调用looper.prepare的线程内创建处理程序

注意:我知道有很多与此相关的问题,但我仍然没有说服,所以问.

当我尝试显示对话框时,我无法在线程中创建处理程序而没有调用looper.prepare.

这是我的代码......

//这个方法是根据某个条件从不同的方法调用的,这个条件是在单击按钮时调用的

 private void download() {
    thread = new Thread() {
     public void run() {
    /**** Downloads each tour's Tour.plist file ****/
            try {
                // do many heavy operations here, like download, 
                //calling web webvice and starting another activity

               This comes at the end

                Intent toAudio = new Intent(TourDescription.this,Audio.class);
                startActivity(toAudio);
         } catch (Exception e) {
       }  

       }
    }; 
    thread.start();
 }
Run Code Online (Sandbox Code Playgroud)

在此行为被调用之前,我正试图展示一个对话框.我试着在调用Intent之前放置它.

任何人都可以告诉我如何做到这一点,因为我不明白如何解决这个问题

multithreading android dialog handler

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

使用FrameLayout在文本视图上放置文本视图

下面是我设计我的xml的方法.现在,我正在尝试在下面显示的白框内插入textview.但是受到FrameLayout的限制(至少我认为是这样)我需要硬编码值以使文本视图适合中间或白盒内的某些位置.我不能为此目的使用相对或其他布局,因为我已经通过我的试验理解,因为整体是单个图像.

这是我的布局,

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:visibility="visible" android:layout_marginTop="60dip"
    android:layout_gravity="center" android:id="@+id/xxx">

    <ImageView android:id="@+id/calloutquizImage" 
        android:background="@drawable/callout" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:scaleType="fitCenter" />

    <ImageView android:id="@+id/triviaImage"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_alignTop="@+id/calloutquizImage" android:layout_gravity="left"
        android:src="@drawable/trivia" android:background="@drawable/trivia"
        android:layout_marginTop="50dip" android:layout_marginLeft="85dip"></ImageView>

    <TextView android:text="TextView" android:id="@+id/triviAnswerText"
        android:layout_marginTop="125dip" android:layout_marginLeft="85dip"
        android:layout_gravity="left" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:textColor="#000000"
        android:typeface="sans"></TextView>

    <ImageButton android:id="@+id/triviaanswercloseButton"
        android:src="@drawable/closebtn" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:background="@drawable/closebtn"
        android:layout_marginRight="8dip" android:layout_marginTop="43dip"
        android:layout_gravity="right" android:onClick="triviaanswerClose"></ImageButton>
    <ImageView android:id="@+id/buttontoclose"
        android:layout_gravity="left"
        android:visibility="visible" android:onClick="triviaanswerClose" 
        android:layout_marginTop="50dip" android:layout_marginLeft="75dip"
        android:layout_width="230dip" android:layout_height="170dip"></ImageView>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

因此,文本视图在各种手机中看起来处于不同的位置.

任何猜测可以为此做些什么呢?

以下是我的形象:

在此输入图像描述

android relativelayout android-layout android-framelayout

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

在parcelable中解组很困难

这是我写入包裹的代码

public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(poiDescription);
        dest.writeString(latitude);
        dest.writeString(longitude);
        dest.writeString(placeName);
        dest.writeString(plistPath);
        dest.writeString(poiDirName);
            if (null != isMascotPresent)
                dest.writeString(isMascotPresent);
            if (null != startMascottTime)
                dest.writeInt(startMascottTime);
            if (null != mascottDuration)
                dest.writeInt(mascottDuration);
}

public PointOfInterest(Parcel source) { 
        poiDescription = source.readString();
        latitude = source.readString();
        longitude = source.readString();
        placeName = source.readString();
        plistPath = source.readString();
        poiDirName = source.readString();
        audioLinkDownload = source.readString();
        audioLinkStream = source.readString();
        poiName = source.readString();
        poiIndex = source.readInt();
        poiPaused = source.readString();
        source.readList(imageList, null);
        source.readList(durationList, null);
        if (null != isMascotPresent)
            isMascotPresent = source.readString();
        if (null …
Run Code Online (Sandbox Code Playgroud)

android unmarshalling parcelable runtimeexception

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