小编Svi*_*lav的帖子

如何以编程方式将按钮逐行添加到几行中?

如何在几行中逐个创建按钮列表?我做的:

LinearLayout layout = (LinearLayout) findViewById(R.id.linear_layout_tags);
    for (int i = 1; i < 10; i++) {
        Button btnTag = new Button(this);
        btnTag.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        btnTag.setText("Button " + i);
        btnTag.setId(i);
        layout.addView(btnTag);
        ((Button) findViewById(i)).setOnClickListener(this);
    }
Run Code Online (Sandbox Code Playgroud)

并且只有一行:

我懂了
如何以编程方式进入下一行?

android button

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

ListView和onItemClick中的可聚焦EditText

ListView我的每个项目中EditText.

当我设置android:focusable="false"EditText然后onItemClickListView项目正在工作,但EditTextclick在里面时没有得到光标.

如果我将设置android:focusable="true"EditText,则EditText可获得焦点,但onItemClick对于ListView当我点击它不工作.

如何分离onItemClick和关注EditText这个项目?

android focusable android-listview onitemclick

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

如何将 pgx.Rows 从 Query() 转换为 json 数组?

我正在使用github.com/jackc/pgxpostgreSQL 进行工作。不,我想将 pgx.Rows 从 Query() 转换为 json 数组。我尝试了 func *sql.Rows,但它不起作用*pgx.Rows

func PgSqlRowsToJson(rows *pgx.Rows) []byte {
   fieldDescriptions := rows.FieldDescriptions()
   var columns []string
   for _, col := range fieldDescriptions {
    columns = append(columns, col.Name)
   }

   count := len(columns)
   tableData := make([]map[string]interface{}, 0)
   values := make([]interface{}, count)
   valuePtrs := make([]interface{}, count)
   for rows.Next() {
    for i := 0; i < count; i++ {
        valuePtrs[i] = &values[i]
    }
    rows.Scan(valuePtrs...)
    entry := make(map[string]interface{})
    for i, col := range columns {
        var …
Run Code Online (Sandbox Code Playgroud)

postgresql go

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

如何在<intent-filter>的帮助下启动MAIN活动?

当我在这个主要方面宣布我的主要活动时:

<activity android:name=".MyActivity"
          android:configChanges="orientation|keyboardHidden"
          android:windowSoftInputMode="stateHidden"
          android:screenOrientation="portrait">
    <intent-filter>
          <action android:name="android.intent.action.MAIN"/>
          <action android:name="com.package.name.MyActivity"/>
          <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

然后我No Activity found to handle Intent { act=com.package.name.MyActivity flg=0x24000000 }在使用此代码时出错:

Intent intent = new Intent("com.package.name.MyActivity");
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

如果不使用Intent i = new Intent(this, MyActivity.class);我怎么能做到这一点的帮助下action进行<intent-filter>

没有帮助:

 <intent-filter>
      <action android:name="android.intent.action.MAIN"/>
      <action android:name="com.package.name.VIEW"/>
      <category android:name="android.intent.category.LAUNCHER" />
 </intent-filter>
Run Code Online (Sandbox Code Playgroud)

码:

Intent intent = new Intent("com.package.name.VIEW");
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

android intentfilter

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

将数据发送到旧活动

我通过使用Flags开始我的旧Activity,Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP但我不能通过使用以下方法将String发送到此Activity putExtra:

Intent intent = new Intent(INTENT_ActivityA);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("DATA", "OK");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

在里面 onResume getIntent().getStringExtra("DATA")==null

如何将数据发送到正在运行的Activity?

android android-intent

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

如何在选项卡选项卡上禁用FragmentPagerAdapter中第一个Fragment的重新创建?

onCreateView因为我在FragmentPagerAdapter中的第一个片段不是很快.因此,将curent tab更改为第一个有延迟.

如何禁用在选项卡选项卡上的FragmentPagerAdapter中重新创建第一个片段?

private class TabsAdapter extends FragmentPagerAdapter implements ViewPager.OnPageChangeListener, ActionBar.TabListener {
    private final Context context;
    private ActionBar bar;
    private final ViewPager viewPager;
    private final ArrayList<TabInfo> tabs = new ArrayList<TabInfo>();

    final class TabInfo {
        private final Class<?> clss;
        private final Bundle args;

        TabInfo(Class<?> _class, Bundle _args) {
            clss = _class;
            args = _args;
        }
    }

    TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) {
        super(activity.getSupportFragmentManager());
        context = activity;
        bar = activity.getSupportActionBar();
        viewPager = pager;
        viewPager.setAdapter(this);
        viewPager.setOnPageChangeListener(this);
    }

    public void addTab(ActionBar.Tab tab, Class<?> clss, …
Run Code Online (Sandbox Code Playgroud)

android android-actionbar fragmentpageradapter

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

为什么在ICS中我的ProgressDialog不像自定义ProgressDialog?

我用android ver在Transformer Prime 201上安装了我的.apk .4.0.3但是ProgressDialog看起来不像设备上的自定义ProgressDialog.

为什么会这样?在设备上使用自定义ProgressDialog样式的代码中,我必须更改哪些内容?

ProgressDialog progressDialog = new ProgressDialog(this.context);
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(true);
progressDialog.setOnCancelListener(this);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setMessage(MESSAGE);
progressDialog.show();
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述 在此输入图像描述

android styles progressdialog android-4.0-ice-cream-sandwich

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

初始化字段哪个更好?

初始化字段哪个更好?在构造函数(var.1)声明(var.2)中

变种.1

public class UtilWebLoading {
private int data;
private Context context;

public UtilWebLoading(Context context) {
    this.context = context;
    data = 100;
}
...
}
Run Code Online (Sandbox Code Playgroud)

变种.2

public class UtilWebLoading {
private int data = 100;
private Context context;

public UtilWebLoading(Context context) {
    this.context = context;
}
...
}
Run Code Online (Sandbox Code Playgroud)

java android

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