我有点问题ListView.如何清除ListView内容,知道它有自定义适配器?
edit- 自定义适配器类扩展BaseAdapter,它看起来像这样:
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class MyAdapter extends BaseAdapter {
private Activity activity;
private String[] data;
private static LayoutInflater inflater = null;
public MyAdapter(Activity a, String[] str) {
activity = a;
data = str;
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public static class ViewHolder {
public TextView text;
}
@Override
public int getCount() {
return data.length;
}
@Override
public Object getItem(int …Run Code Online (Sandbox Code Playgroud) 我的应用程序通过TCP连接发送文件(所有mime类型),因此我希望我的应用程序出现在Android Share菜单中.
我在我的Activity中添加了以下intent过滤器 AndroidManifest.xml
<intent-filter ><!--intent filter for single file sharing-->
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter ><!--intent filter for sharing multiple files-->
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
现在我将其添加到Activity单击"共享操作"时要启动的内容
Intent intent = getIntent();
if (Intent.ACTION_SEND.equals(intent.getAction())) {
Uri uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (uri != null) {
fileset = new HashSet();
fileset.add(getPathfromUri(uri));
}
} else if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())) {
ArrayList<Uri> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
if (uris != null) {
fileset = …Run Code Online (Sandbox Code Playgroud) 如何从boostrap container-fluid类及其行中删除所有边距?
.container-fluid { padding: 0;}
Run Code Online (Sandbox Code Playgroud)
这基本上是我想要的,但它增加了20px溢出到身体.我应该这样做:
body, html { overflow-x: hidden; }
Run Code Online (Sandbox Code Playgroud)
做点什么 .container-fluid > .row
我是新手,所以我想知道为什么我需要使用这些指令
%option nounput
%option noinput
Run Code Online (Sandbox Code Playgroud)
是的,我知道否则我会有这些警告:
lex.yy.c:1237:17: warning: ‘yyunput’ defined but not used [-Wunused-function]
static void yyunput (int c, register char * yy_bp )
^
lex.yy.c:1278:16: warning: ‘input’ defined but not used [-Wunused-function]
static int input (void)
^
Run Code Online (Sandbox Code Playgroud)
这些指令在flex中实际上是什么问题?在这种情况下,我将能够使用这些功能(为什么):
static void yyunput (int c, register char * yy_bp );
static int input (void);
Run Code Online (Sandbox Code Playgroud)
有什么用?
我写了这段代码,在软件启动时从数据库(MYSQL控制中心)获取数据并将它们带到表中。但是,当我编译此代码2时会发生错误。
Note: C:\Users\Commander Shepard\Documents\NetBeansProjects\Furniture Management System\src\furnituremanagementsystem\employee.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Run Code Online (Sandbox Code Playgroud)
我的代码:
public class employee extends javax.swing.JFrame {
// Creates new form employee
public employee() {
initComponents();
Date now = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
datelabel.setText(formatter.format(now));
try {
Statement s = DB.getConnection().createStatement();
DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
dtm.setRowCount(0);
ResultSet r = s.executeQuery("SELECT * from Employee");
while (r.next()) {
Vector v = new Vector();
v.add(r.getString(1));
v.add(r.getString(2));
v.add(r.getString(3));
v.add(r.getString(4));
v.add(r.getString(5));
v.add(r.getString(6));
v.add(r.getString(7));
v.add(r.getString(8));
v.add(r.getString(9)); …Run Code Online (Sandbox Code Playgroud) 为什么我们在退出流程时使用42作为退出的参数?我想知道它是一些宏值(如1是EXIT_FAILURE宏的值)还是有一些更深层的含义?
if(pid == 0) {
printf("something\n");
exit(42);
}
Run Code Online (Sandbox Code Playgroud)
很明显,如果我使用退出(1)或退出(42)无关紧要,但为什么只有42?
如何使用选择器更改按钮的 DrawableLeft 图像?
我正在使用以下选择器文件和用于 drawable 的形状 XML。单击按钮时,图像不会改变。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:drawable="@drawable/toolbar_button_pressed"
android:drawableLeft="@drawable/ic_selected" />
<item android:state_pressed="true"
android:drawable="@drawable/toolbar_button_pressed"
android:drawableLeft="@mipmap/ic_selected" />
<item android:drawable="@drawable/toolbar_button_normal" />
</selector>
Run Code Online (Sandbox Code Playgroud)
toolbar_button_pressed
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="10dp" />
<solid android:color="@color/primary_dark" />
<padding android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
<stroke android:width="1dp"
android:color="@color/divider" />
</shape>
Run Code Online (Sandbox Code Playgroud)
布局按钮
<Button android:id="@+id/background_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_background"
android:drawableLeft="@drawable/ic_background"
style="@style/ToolbarButton"
android:drawablePadding="10dp"
android:singleLine="true"
android:layout_weight="1" />
Run Code Online (Sandbox Code Playgroud) 我正在为我的微调器使用自定义设计,但文本在微调器的右侧图标上重叠。请查看所附图片。
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:spinnerMode="dialog"
android:background="@drawable/spinner_bg"
android:id="@+id/mySpinner"
android:prompt="Testing"
android:layout_marginTop="8dp" />
Run Code Online (Sandbox Code Playgroud)
spinner_bg.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
<item>
<shape>
<gradient
android:startColor="#6e95bd"
android:endColor="#517295"
android:angle="270" />
<stroke
android:width="1dp"
android:color="#000" />
<corners
android:radius="50dp" />
</shape>
</item>
<item>
<bitmap android:gravity="right|center_vertical" android:src="@mipmap/ic_spinner_down"/>
</item>
</layer-list>
</item>
</selector>
Run Code Online (Sandbox Code Playgroud)