小编use*_*394的帖子

如何知道Android设备的最小宽度(sw)?

我有4种不同的设备:

  1. 华硕平板电脑,屏幕7"
  2. 联想平板电脑,屏幕尺寸7"
  3. HTC手机屏幕5英寸
  4. HTC手机,屏幕尺寸4.7"

我想知道我的设备的最小宽度(sw)为它做一个支撑布局.

我想创建一个像"layout-sw600dp"这样的资源文件夹,但我不知道最小宽度(sw)的值.

我尝试使用以下代码打印sw:

DisplayMetrics metrics = getResources().getDisplayMetrics();
Log.i("Density", ""+metrics.densityDpi);
Run Code Online (Sandbox Code Playgroud)

但我不知道这是否是正确的价值.

如何找到最小宽度(sw)?

android android-screen-support android-resources

20
推荐指数
5
解决办法
9518
查看次数

Listview itemclick无效

  1. 我的ListView中有一个ListView显示ImageButton.

  2. 我将focusalble"false"和focusableInTouchMode"false"设置为ImageButton.

  3. 我设置了ListView.OnItemClickListner.当我运行我的项目它显示我的ListView.

  4. 但是当我点击Listview它不起作用.

  5. 然后我在布局中删除ImageButton并在我单击ListView它工作时再次运行我的项目

  6. 怎么了?

android listview

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

PopupWindow onitemclick中的Android Listview无法在某些设备上运行

我的ListView在PopupWindow中.

当我显示PopupWindow并点击设备ASUS K00z fonepad中的Listview行时非常好.

但在HTC Z715e不工作(onitem点击事件未被解雇)

这是我的listview项目布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ln_testpopitemcon"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="52dp"
    android:background="#3b8ed4"
    android:descendantFocusability="blocksDescendants">

<ImageView
    android:id="@+id/img_testiconmenu"
    android:layout_margin="10dp"
    android:layout_width="32dp"
    android:layout_height="32dp"
    android:src="@drawable/radio_selected"
    android:clickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false"/>

    <TextView
        android:id="@+id/tv_testtitlemenu"
        android:gravity="left|center_vertical"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:clickable="false"
        android:focusable="false"
        android:focusableInTouchMode="false"/>

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

这是我的弹出式布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ln_testpopocontainer"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:paddingLeft="2dp"
        android:paddingRight="2dp"
        android:paddingBottom="2dp"
        android:id="@+id/lv_testpop"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:choiceMode="singleChoice"
        android:dividerHeight="2dp"
        android:background="#00000000"
        android:orientation="vertical"/>

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

这是我的适配器

public class testmenuadapter extends BaseAdapter{
    private Context context;
    private ArrayList<MenuInfo> MenuList;
    private LayoutInflater Layf;

    public testmenuadapter(Context context, ArrayList<MenuInfo> menuList){
        this.context = context;
        this.MenuList = menuList;
        this.Layf = …
Run Code Online (Sandbox Code Playgroud)

android android-listview onitemclicklistener android-popupwindow

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

如何在GMSMapView上实现GMSMarker拖放?

  1. 我在谷歌地图上设置了标记但是当我拖动它时,所有的地图都是拖动的.

  2. 点击并拖动时我想要拖动标记

  3. 单击并拖动标记外拖动地图.

这是我的代码

self.camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:6 bearing:0 viewingAngle:0];
self.Map = [GMSMapView mapWithFrame:self.MapView.bounds camera:self.camera];
self.Map.myLocationEnabled = YES;
self.Map.delegate = self;

GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = self.camera.target;
marker.draggable = YES;
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = self.Map;
marker.icon = [GMSMarker markerImageWithColor:[UIColor blueColor]];
marker.appearAnimation = kGMSMarkerAnimationPop;

[self.MapView addSubview:self.Map];
Run Code Online (Sandbox Code Playgroud)

这是拖拽事件

- (void) mapView:(GMSMapView *)mapView didBeginDraggingMarker:(GMSMarker *)marker
{

}

- (void) mapView:(GMSMapView *)mapView didEndDraggingMarker:(GMSMarker *)marker
{

}

- (void) mapView:(GMSMapView *)mapView didDragMarker:(GMSMarker *)marker
{

}
Run Code Online (Sandbox Code Playgroud)

当我运行我的应用程序并调试所有上述事件不起作用.但事件点击标记工作很好. …

google-maps drag-and-drop objective-c ios google-maps-sdk-ios

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

如何知道哪种颜色支持GMSMarker?

我想在谷歌地图上创建20个不同的标记.

当我从RGB设置UIColor时,某些颜色不匹配.

teamColor = [UIColor colorWithRed:255.0/255.0 green:250.0/255.0 blue:229.0/255.0 alpha:1]
marker.icon = [GMSMarker markerImageWithColor:teamColor];
//when i set marker to this colour it's show different i want
Run Code Online (Sandbox Code Playgroud)

当我设置黑色或白色时,它会显示加里.

如何知道哪种颜色支持GMSMarker?

google-maps ios xcode5 gmsmapview

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

如何在WebView Android上自动播放iframe YouTube

我在我的应用程序中使用android webview来显示来自youtube的视频,效果很好。

但我希望它是自动播放的。

这是我的活动,我在videoUrl后面附加了“?autoplay = 1”,但没有任何变化,它仍然不是自动播放。

public class LandVideoAct extends Activity {
    WebView mWebView;
    String videoURL = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.landfull);
        videoURL = "http://www.youtube.com/embed/VYIi49czywo?autoplay=1";
        mWebView = (WebView) findViewById(R.id.fullwebview);

        String vid = "<html><body style=\"margin: 0; padding: 0\"><iframe  width=\"100%\" height=\"100%\" src=\""+videoURL+"\" type=\"text/html\" frameborder=\"0\"></iframe><body><html>";

        WebChromeClient mWebChromeClient = new WebChromeClient(){
            public void onProgressChanged(WebView view, int newProgress) {
            }
        };

        mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
        mWebView.setWebChromeClient(mWebChromeClient);
        mWebView.setWebViewClient(new WebViewClient() {
            public void onPageFinished(WebView view, String url) {
                mWebView.loadUrl("javascript:(function() { document.getElementsByTagName('video')[0].play(); })()"); 
            } …
Run Code Online (Sandbox Code Playgroud)

youtube iframe android webview

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

如何在同一时间悬停多个"div"?

我有

<div id="d1" class="hov"></div>
Run Code Online (Sandbox Code Playgroud)

<div id="d2" class="hov"></div>
Run Code Online (Sandbox Code Playgroud)

而CSS则是

.hov:hover{
    background-color:#cde0c4;
    cursor:pointer;
}
Run Code Online (Sandbox Code Playgroud)

当我在d1上盘旋时,我希望d2悬停相同.如何同时悬停多个DIV?

html javascript css

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