小编Ron*_*TLV的帖子

char数组如何存储在内存中?

我对char数组的内存地址感到困惑.这是演示代码:

char input[100] = "12230 201 50";
const char *s = input;
//what is the difference between s and input?

cout<<"s = "<<s<<endl;                    //output:12230 201 50
cout<<"*s = "<<*s<<endl;                  //output: 1

//here I intended to obtain the address for the first element
cout<<"&input[0] = "<<&(input[0])<<endl;  //output:12230 201 50
Run Code Online (Sandbox Code Playgroud)

char数组本身是指针吗?为什么&运算符不给出char元素的内存地址?如何获取个别条目的地址?谢谢!

c++

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

全屏 TextInputEditText 不显示计数器

我正在尝试使TextInputEditText适合整个屏幕,但并非没有问题:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:orientation="vertical"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="16dp"
    tools:context=".MainActivity">

    <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:counterEnabled="true"
        app:counterMaxLength="1000"
        app:passwordToggleEnabled="false"
        app:endIconMode="none">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/edit_text"
            android:hint="Type here..."
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:maxLength="1000"
            android:gravity="top"/>

    </com.google.android.material.textfield.TextInputLayout>

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

输入类型:

TextInputEditText tv = findViewById( R.id.edit_text );
tv.setInputType( InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE );
Run Code Online (Sandbox Code Playgroud)

结果是计数器不见了,提示出现在中间。如果我更改为包装内容,它将恢复正常行为。例子:

在此处输入图片说明

所以基本上我会满足于只显示计数器,将提示对齐到顶部是次要的。

android

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

分享时将标题文字加粗

在这里,下面的代码将分享 onclick 的内容。通过其他应用分享内容时,有两种内容:一种是标题,另一种是描述。我想在分享时将标题加粗。那可能吗?

expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

    @Override
    public boolean onChildClick(ExpandableListView parent, View v,
                                int groupPosition, int childPosition, long id) {
        // TODO Auto-generated method stub

        TextView de = (TextView) v.findViewById(R.id.lblListItem);
        TextView ti = (TextView) v.findViewById(R.id.lblListHeader);


        String selected = ti.getText().toString() + de.getText().toString();
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, selected);
        startActivity(Intent.createChooser(intent, "Share via"));

        return false;
    }
});
Run Code Online (Sandbox Code Playgroud)

java android share-intent

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

标签 统计

android ×2

c++ ×1

java ×1

share-intent ×1