|
package net.blogjava.mobile;
import android.app.Activity;
package net.blogjava.mobile;
import android.app.Activity;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class bailiao extends Activity implements
OnClickListener
{
private EditText metMessageList;
private EditText metMessage;
public void onClick(View view)
{
String msg = metMessage.getText().toString();
if (!"".equals(msg))
{
try
{
metMessage.setText("");
metMessageList.append("我:\n");
metMessageList.append(msg + "\n\n");
MessageReceiver(msg);
}
catch (Exception e)
{
// TODO: handle exception
}
}
}
public void MessageReceiver(String account)
{
metMessageList.append("小书虫:\n");
metMessageList.append("a"+ "\n\n");
}
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
metMessageList = (EditText) findViewById(R.id.etMessageList);
metMessage = (EditText) findViewById(R.id.etMessage);
Button btnSend = (Button) findViewById(R.id.btnSend);
btnSend.setOnClickListener(this);
}
}
复制代码
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
public class Text1Activity extends Activity implements OnItemClickListener
{
private static String[] data = new String[]
{ "与手机聊天", "设置"};
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id)
{ if(position==0)
{
Intent intent=new Intent(Text1Activity.this, bailiao.class);
// intent.setClass(this, bailiao.class);
startActivity(intent);
this.finish();//关闭当前Activity
}
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView lvCommonListView = (ListView) findViewById(R.id.lvCommonListView);
ArrayAdapter<String> aaData = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, data);
lvCommonListView.setAdapter(aaData);
lvCommonListView.setSelection(0);
lvCommonListView.setOnItemClickListener(this);
//lvCommonListView.setOnItemSelectedListener(this);
}
}
各位前辈,鄙人刚刚接触android,出现一点问题,我想通过 “点击列表中的一项而进入另一个activity,不知道哪里出错,希望高手指点!!”,代码如下: |
|