Я работаю над Custom TextView, но я очень разочарован этим.IKK, как завершить код .... Мой код:
public class TestTextView extends TextView{
static BluetoothSocket mSocket;
Context c;
public TestTextView(Context mContext){
super(mContext);
mBTConnected(c);
}
public static boolean mBTConnected(Context c){
String mOutputName;
Method m;
try{
BluetoothDevice mDevice=BluetoothAdapter.getDefaultAdapter().getRemoteDevice("MAC_ADRS");
m=mDevice.getClass().getMethod("createRfcommSocket", new Class[]{int.class});
mSocket=(BluetoothSocket)m.invoke(mDevice, Integer.valueOf(1));
mSocket.connect();
mOutputName=mDevice.getName().toString();
Log.i("Bluetooth device "+mOutputName," is connected");
return true;
}catch(Exception e){
}return false;
}}
Вопрос: Как установить имя строки в качестве текста для пользовательского TextView, чтобы вызвать его в моем файле макета Xml?
LOG:
10-10 17:34:14.900 E/SDAgentPackageStateReceiver(3797): Not going to handle 'com.mort015.BluetoothTextView'! 10-10 17:34:15.055 E/SDAgentPackageStateReceiver(3797): Not going to handle 'com.mort015.BluetoothTextView'! 10-10 17:34:18.610 E/SPPClientService(9467): [PackageInfoChangeReceiver] [handlePkgRemovedEvent] PackageName : com.mort015.BluetoothTextView, true, false 10-10 17:34:24.237 E/AndroidRuntime(30755): Process: com.mort015.BluetoothTextView, PID: 30755 10-10 17:34:24.237 E/AndroidRuntime(30755): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mort015.BluetoothTextView/com.mort015.BluetoothTextView.MainActivity}: android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class com.mort015.BluetoothTextView.TestTextView 10-10 17:34:24.237 E/AndroidRuntime(30755): Caused by: android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class com.mort015.BluetoothTextView.TestTextView 10-10 17:34:24.237 E/AndroidRuntime(30755): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.mort015.BluetoothTextView.TestTextView 10-10 17:34:24.237 E/AndroidRuntime(30755): at com.mort015.BluetoothTextView.MainActivity.onCreate(MainActivity.java:17) 10-10 17:34:24.562 E/cm_cmc_c(5288): app launch:com.mort015.BluetoothTextView