小编use*_*936的帖子

使用gradle构建库项目时,BuildConfig.DEBUG始终为false

当我在调试模式下运行我的应用程序时,BuildConfig.DEBUG无效(=逻辑设置为false).我用Gradle来构建.我有一个图书馆项目,我在这里检查.BuildConfig.java在构建调试文件夹中看起来像这样:

/** Automatically generated the file. DO NOT MODIFY */
package common.myProject;

public final class BuildConfig {
    public static final boolean DEBUG = Boolean.parseBoolean("true");

}
Run Code Online (Sandbox Code Playgroud)

并在发布文件夹中:

public static final boolean DEBUG = false;
Run Code Online (Sandbox Code Playgroud)

在库项目和应用程序项目中.

我试图通过检查一个设置了我的项目类的变量来解决这个问题.该类继承自库并在启动时启动.

<application
        android:name=".MyPrj" ...
Run Code Online (Sandbox Code Playgroud)

这导致了另一个问题:我在应用程序类之前运行的DataBaseProvider中使用我的DEBUG变量,并且由于此错误它将无法正常运行.

android gradle android-library

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

Android:class not found exception:android.support.v4.app.FragmentPager

在我的代码中我导入android.support.v4.view.ViewPager 但是ClassNotFoundException: android.support.v4.view.ViewPager当我将内容视图设置为此xml文件时,我得到了一个:

...
 <android.support.v4.app.FragmentPager 
     android:layout_height="0px" 
     android:layout_width="match_parent" 
     android:layout_weight="1" 
     android:id="@+id/pager"> 
     </android.support.v4.app.FragmentPager>
...
Run Code Online (Sandbox Code Playgroud)

android classnotfoundexception

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

Android:线性布局新线

我使用TextView创建了如下的LinearLayout.文本是可变的.如果元素大于布局宽度,它会变得讨厌.我想让文本流到一个新行,就像写书一样.这可能吗?

<LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

<TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="xx"
            android:textAppearance="?android:attr/textAppearanceSmall" />

<EditText ...>

<TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="xx"
            android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

编辑

像这样:

  1. textview1text edittext textview2
  2. textview2continuesin2ndrow

不是这样的:

  1. textview1text edittext textview2text
  2. textview1cont

android

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

进度条有2个指标

我想要有2个指标的进度条.

一个指示器以绿色显示任务A的进度,第二个指示器以红色显示任务B的进度,全部在一个进度条中.其余部分显示了剩余的任务A和B.

是否有(简单)解决方案来实现这一目标?我阅读了文档,但没有找到帮助.

android greenfoot progress-bar

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


选中查看外部的单击

这是我的布局:

<?xml version="1.0" encoding="utf-8"?><!-- Style Theme.Transparent -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayoutVideo"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:weightSum="1"
    android:focusable="true"
    android:clickable="true">

    <VideoView
        android:id="@+id/videoView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.75"
        android:clickable="true"
        android:focusable="true" />

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

我将onclicklistener设置为父视图和子视图:

linearLayout.setOnClickListener(myOnlyhandler);
videoView.setOnClickListener(myOnlyhandler);
Run Code Online (Sandbox Code Playgroud)

我只获得视频观看的点击事件.我想要的是知道用户是否点击进入视频视图或外部(父)并执行不同的操作.我该如何得到这种行为?

谢谢塔塔

layout android

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

Android:支持包Fragment

我试过这个例子

http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentPagerSupport.html

我为API Level 15构建并使用支持包.这种功能引发了麻烦:

@Override
        public Fragment getItem(int position) {
            return ArrayListFragment.newInstance(position);
        }
Run Code Online (Sandbox Code Playgroud)

错误信息:

返回类型与FragmentPagerAdapter.getItem(int)不兼容

我发现了类似的问题,但没有明确的解决方案我 无法从android.support.v4.app.Fragment转换为android.app.Fragment

android

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

如何使用SimpleAdapter.ViewBinder?

我有一个复杂布局的列表R.layout.menu_row.它由一个ProgressBar和一个文本字段组成.我使用的适配器:

   SimpleAdapter simpleAdapter = new SimpleAdapter(this, getData(path),
            R.layout.menu_row, new String[] { "title", "progress" },
            new int[] { R.id.text1,R.id.progressBar1});
Run Code Online (Sandbox Code Playgroud)

适配器知道如何自己处理TextViews但不是ProgressBars,所以我编写了一个复杂的数据绑定器:

    SimpleAdapter.ViewBinder viewBinder = new SimpleAdapter.ViewBinder() {
        @Override
        public boolean setViewValue(View view, Object data, String textRepresentation) {
            //here goes the code
            if () {
                return true;
            }
            return false;
        }
Run Code Online (Sandbox Code Playgroud)

现在我被困在函数内填充映射.我需要将string的值设置progresssetProgress方法ProgressBar.但我没有得到字符串progress和句子的句柄ProgressBar.

android android-progressbar simpleadapter android-viewbinder

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

Android:访问OnClickListener中的视图元素

我有一个Fragment容器和片段外的一些按钮,它们与片段的内容相互作用.当我点击按钮时,我需要获取文本元素内的信息.这就是我现在所拥有的,但它不起作用.代码来自片段寻呼机演示.

Button bm = (Button) findViewById(R.id.bm);
bm.setOnClickListener(new OnClickListener() {
  public void onClick(View v) {
    EditText editTextIn1 = (EditText) v.findViewById(R.id.editTextIn1);
  }
});
Run Code Online (Sandbox Code Playgroud)

编辑我使用这个示例:

http://developer.android.com/reference/android/support/v13/app/FragmentStatePagerAdapter.html

public class FragmentStatePagerSupport extends FragmentActivity {
    static final int NUM_ITEMS = 10;

    MyAdapter mAdapter;

    ViewPager mPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_pager);

        mAdapter = new MyAdapter(getSupportFragmentManager());

        mPager = (ViewPager)findViewById(R.id.pager);
        mPager.setAdapter(mAdapter);

        // Watch for button clicks.
        Button button = (Button)findViewById(R.id.goto_first);
        button.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                mPager.setCurrentItem(0);
            }
        });
        button = (Button)findViewById(R.id.goto_last);
        button.setOnClickListener(new OnClickListener() …
Run Code Online (Sandbox Code Playgroud)

android

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