我正在开发某种聊天应用程序,一切都很顺利,但我遇到了一个问题.EditText滞后,每当我在edittext中输入一些字母时,我的android键盘会在第二次或某些时候被冻结.我真的不知道要提供什么代码,因为它只是一个简单的EditText框.这是我如何做到的:
linforbutton.add(new LinearLayout(this)); //linear layout on the bottom os creen for edittext and button
RelativeLayout.LayoutParams params =
new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
linforbutton.get(x).setLayoutParams(params);
linforbutton.get(x).setBackgroundColor(0xff426193);
linforbutton.get(x).setOrientation(LinearLayout.HORIZONTAL);
int padding_in_dp1 = 3;
final float scale1 = getResources().getDisplayMetrics().density;
int padding_in_px1 = (int) (padding_in_dp1 * scale1 + 0.5f);
linforbutton.get(x).setPadding(0, 0, 0, 0);
relmsg.get(x).addView(linforbutton.get(x));
msginput.add(new EditText(this));
msginput.get(x).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
msginput.get(x).setMaxLines(3);
msginput.get(x).setMinLines(1);
msginput.get(x).setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
msginput.get(x).setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
msginput.get(x).setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
msginput.get(x).setImeOptions(EditorInfo.IME_ACTION_SEND);
msginput.get(x).setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
linforbutton.get(x).addView(msginput.get(x));
btninput.add(new Button(this));
btninput.get(x).setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
btninput.get(x).setText("????.");
int padding_in_dp2 = 20;
final float scale2 = getResources().getDisplayMetrics().density;
int padding_in_px2 = (int) …Run Code Online (Sandbox Code Playgroud) 我想要的是在for循环示例中创建多个视图
for(int i =1; i<5; i++){
GridView view = new Gridview(this);
}
Run Code Online (Sandbox Code Playgroud)
但是它创建了5个具有相同名称的gridview ..所以将来我不能为特定的gridview设置不同的选项.我如何得到,在循环中创建的gridivew获取视图+我的名字
我需要以某种方式这样做:

我尝试使用相对布局,我放置了顶部的imageview和底部按钮但是如何将我的gridview放在中心?但是在顶部图像和底部按钮之间?
我一直在寻找很多.但找不到任何东西.我需要用rosterlistener刷新联系人的状态.(离线/在线).创建名单时,我做:
Presence presence = roster.getPresence(r.getUser());
if(presence.isAvailable()){
userstatus.add("online");
}else{
userstatus.add("offline");
}
Run Code Online (Sandbox Code Playgroud)
userstatus是一个矢量字符串,然后我从中创建一个字符串数组.在我的主程序中,我只是检查这个搅拌阵列的离线或在线.但是,如果用户离线/在线,该怎么办.究竟我必须把听众以及如何使用它?
我有一个textview,其中我以两种方式附加文本:第一种方式:通过单击按钮并获取EditText中的内容.
sendbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
txview.append("Text: "+txedit.getText()+"\n");
txedit.setText("");
}
});
Run Code Online (Sandbox Code Playgroud)
这工作正常,当我点击按钮textview用新文本更新视图.
但
第二种方式,我听xmpp监听器(asmack库)和接收消息我将它追加到textView.
chat = xmpp.getChatManager().createChat(contactid[1], new MessageListener() {
public void processMessage(Chat chat, Message message) {
try {
chat.sendMessage(message.getBody());
} catch (XMPPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} txview.append("Text"+message.getFrom()+"\n"+message.getBody()+"\n"); } }
);;
Run Code Online (Sandbox Code Playgroud)
问题是,我收到消息,我肯定知道它(因为我用chat.sendMessage(message.getBody());)重新发送给用户,但是 textview只在我更改视图或获取应用程序之后显示我的消息背景(单击主页按钮),然后将其恢复到前面.
我试图 在每个视图上调用invalidate(),根本不起作用.
是做任何解决方案或其他方式做我正在做的事情?
我决定在一篇文章中发布两个问题,因为这是完全相同的问题.
我需要知道屏幕何时开启或关闭,以便我可以转动LED.第二个我需要知道我的应用程序是在backgorund还是在前台,以便在应用程序处于后台时管理某些动作的发送通知.
我有一点问题.
第ll类:
interface jj{
public class ll implements gg{
public static String j ="C:\\";
//some code here
}
}
Run Code Online (Sandbox Code Playgroud)
班级ggg:
interface gg{
public class ggg extends JFrame implements jj{
//bunch of code + a textfield
textField = new JTextField();
textField.setBounds(72, 120, 217, 20);
textField.setColumns(10);
//bunch of code
}
}
Run Code Online (Sandbox Code Playgroud)
CLass aaa
public class aaa implements jj, gg {
public aaa(){
//File chooser here + editing strin "j" from class "ll"
File f = chooser.getSelectedFile();
if(f!=null)
{
jj.ll.j = f.getPath();
//And …Run Code Online (Sandbox Code Playgroud) 基本上我需要例如在位置0..9的array1包含从posinion 20..29形成另一个数组的项目.我该怎么做呢?我尝试使用for循环,但这样我只能从两个数组中的相同位置获取数据.