小编Shu*_*oul的帖子

带有圆角的Android标签布局标签

此类问题之前已经被问到,但没有得到任何正确的,有效的解决方案,所以我再次发布这个问题.再次询问并浪费你的时间.请给出一些有效的解决方案 或者让我知道我做错了什么.提前致谢.

预期标签: 在选择Tab时它应该是这样的

但是来了:

即将到来的标签 即将到来的标签

在页面上加载选项卡将像"预期选项卡"图像一样,但在选择后会出现像"即将到来的选项卡"图像. MainXML代码:

 <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                style="@style/MyCustomTabLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/background_img_jpeg"
                android:minHeight="10dp"
                android:padding="10dp"
                app:tabGravity="fill"
                app:tabIndicatorColor="@color/TRANSPARENT"
                app:tabMode="fixed"
                app:tabTextColor="@color/blue" />
Run Code Online (Sandbox Code Playgroud)

@风格/ MyCustomTabLayout

<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
        <item name="tabBackground">@drawable/tab_bg</item>
    </style>
Run Code Online (Sandbox Code Playgroud)

@绘制/ tab_bg

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true"
        android:drawable="@drawable/tab_bgselected" />
    <item android:drawable="@drawable/tab_bgnotselected" />
    </selector>
Run Code Online (Sandbox Code Playgroud)

@绘制/ tab_bgselected

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:bottom="0dp"  android:top="0dp"
          android:left="0dp" android:right="0dp" >
        <shape android:shape="rectangle">
            <solid android:color="@color/blue" />
            <corners
                android:topLeftRadius="10dp"
                android:bottomLeftRadius="10dp">
            </corners>
        </shape>
    </item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)

就像那个@ drawable/tab_bgnotselected

在代码背后我写道:

tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                try { …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-tablayout

11
推荐指数
4
解决办法
7893
查看次数

使用Java在Selenium WebDriver中创建可执行文件

是否可以在java中制作Selenium WebDriver可执行文件?我用java编写了代码,用于使用Selenium WebDriver进行数据驱动测试.我想把它变成可执行文件,以便外部eclipse可以执行它.

package pkg;

import java.util.concurrent.TimeUnit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class LogingS {
  private WebDriver driver;
  private String baseUrl;

  @Before
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "http://www.example.com/";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

  @Test
  public void testLogingS() throws Exception {
    driver.get(baseUrl);
    System.out.println("The current Url: " + driver.getCurrentUrl());
    driver.findElement(By.id("id_email")).clear();
    driver.findElement(By.id("id_email")).sendKeys("com");
    Thread.sleep(1000);
    driver.findElement(By.id("id_password")).clear();
    driver.findElement(By.id("id_password")).sendKeys("123");
    Thread.sleep(1000);
    System.out.println("The current Url: " + driver.getCurrentUrl());
    driver.findElement(By.id("btn_login")).submit();
    Thread.sleep(5000);
    System.out.println("The current Url: " + driver.getCurrentUrl()); …
Run Code Online (Sandbox Code Playgroud)

java eclipse testing selenium-webdriver

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

如何在android中获取gps中使用的卫星数量?

我写得像这样.但我总是0.请纠正我错在哪里.

public int getSatellites() { 

    GpsStatus gpsStatus = locationManager.getGpsStatus(null);
     int count=0;
     if(gpsStatus != null) {
         Iterable<GpsSatellite>satellites = gpsStatus.getSatellites();
         Iterator<GpsSatellite>sat = satellites.iterator();

         int i=0;

         while (sat.hasNext()) {
            count++;
             GpsSatellite satellite = sat.next();
             strGpsStats+= (i++) + ": " + satellite.getPrn() + "," + satellite.usedInFix() + "," 
             + satellite.getSnr() + "," + satellite.getAzimuth() + "," + satellite.getElevation()+ "\n\n";
             Log.v("value:"+"-", strGpsStats+= (i++) + ": " + satellite.getPrn() + "," + satellite.usedInFix() + "," 
                     + satellite.getSnr() + "," + satellite.getAzimuth() + "," + satellite.getElevation()+ "\n\n"); …
Run Code Online (Sandbox Code Playgroud)

gps android

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

如何在警报中显示AJAX响应消息?

我将用户名和密码作为请求参数发送到AJAX中的服务器并尝试显示响应消息.但是无法显示响应消息.在fiddler中它显示响应消息.但是在浏览器屏幕上它没有显示.请有人帮助我,我错了或需要改变任何东西..我写的像这样 -

$(document).ready(function () {
  $("#btnCity").click(function () {
    $.ajax({
      type: "POST",
      url: "http://test.xyz.com/login",
      crossDomain: true,
      contentType: "application/json; charset=utf-8",
      data: { username: "abc", password: "1234" },
      dataType: "JSONP",
      jsonpCallback: 'jsonCallback',
      async: false,
      success: function (resdata) {
        alert(resdata);
      },
      error: function (result, status, err) {
        alert(result.responseText);
        alert(status.responseText);
        alert(err.Message);
      }
    });
  });
});
Run Code Online (Sandbox Code Playgroud)

ajax json

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