これは私のコードです。ここにいくつかのエラーがあり、私はそれを解決することができませんでした。誰でも私を助けることができますか? view.OnClickListenerとView v。でエラーが発生しました。クイックフィックスを使用してエラーを修正すると、別のエラーが表示されます。 plsは私を助ける: '(どのように私はOnClickListener1を修正したいですか
package com.android;
import java.io.BufferedReader;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.io.*;
import android.app.Activity;
import android.os.Bundle;
import android.view.View.OnClickListener;
import android.view.View.*;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Button;
import android.text.Editable;
public class Net extends Activity implements View.OnClickListener
{
EditText edt;
TextView text;
Button ping;
@Override
protected void onCreate(Bundle savedInstanceState) //To do auto generated method
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
edt=(EditText)findViewById(R.id.edt);
text=(TextView)findViewById(R.id.text);
ping=(Button)findViewById(R.id.ping);
Button.setOnClickListener(this);
}
public void onClick(View v) //To do auto generated method
{
Editable host=edt.getText();
}
InetAddress addr=null;
{
Object host;
try
{
addr=InetAddress.getByName(host.toString());
}
catch(UnknownHostException e) //To do auto generated catch block
{
e.printStackTrace();
}
try
{
if(addr.isReachable (5000))
{
text.append("\n" +host+ "-Respond Ok");
}
else
{
text.append("\n"+host);
}
}
catch(IOException e){
text.append("\n"+e.toString());
}
try
{
String pingCmd="ping -c5"+host;
String pingResult="";
Runtime r = Runtime.getRuntime();
Process p = r.exec(pingCmd);
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String inputLine;
while((inputLine = in.readLine())!=null)
{
System.out.println(inputLine);
text.setText(inputLine+"\n\n");
pingResult += inputLine;
text.setText(pingResult);
}
in.close();
}
catch(IOException e)
{
System.out.println(e);
}
TextView tv = new TextView(this);
tv.setText("\t\t\t\t** Network Tracer ** \n\n\t\tWelcome to Android Network Tracer!");
setContentView(tv);
}
}
エラーは何ですか? logcat –
をview.OnClickListenerビューでエラーを送信するv Button.setOnClickListener –