fellows hope you all are doing good.I am dealing with a problem which seems not ending i tried every thing to remove errors but nothing seems to work this is my java code which i am using it would be highly appreciative if you correct it. i imported it from eclipse if you need other code too please let me know.
package com.uichat;
import android.app.Activity;
import android.content.Intent;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AbsListView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import java.io.ByteArrayOutputStream;
public class MainActivity extends Activity{
private ChatArrayAdapter adp;
private ListView list;
private EditText ChatText;
private Button send;
Intent In;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent I = getIntent();
send = (Button) findViewById(R.id.btn);
list = (ListView) findViewById(R.id.list);
adp = new ChatArrayAdapter(getApplicationContext(), R.layout.chat);
ChatText = (EditText) findViewById(R.id.chat);
ChatText.setKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
return sendChatMessage(false);
}
return false;
}
});
send.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
sendChatMessage(false);
}
});
list.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
list.setAdapter(adp);
adp.registerDataSetObserver(new DataSetObserver() {
@Override
public void onChanged() {
super.onChanged();
list.setSelection(adp.getCount() - 1);
}
});
}
private boolean sendChatMessage(boolean side) {
adp.add(new ChatMessage(side, ChatText.getText().toString()));
ChatText.setText("");
side = !side;
return true;
}
public ListView getList() {
return list;
}
public void setList(ListView list) {
this.list = list;
}
class EditView {
private String text;
public void setOnKeyListener(OnKeyListener onKeyListener) {
}
public boolean getText() {
return true;
}
public void setText(String text) {
this.text = text;
}
}
class OnKeyListener {
}
}
Aucun commentaire:
Enregistrer un commentaire