一直报source not found错误

talent1314 2011-10-27 12:02:44
贴代码
string.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, GetDeviceInfo!</string>
<string name="app_name">apple</string>
<string name="newact">apple1</string>
</resources>

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>


css.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView
android:text="TextView"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
</TextView>



GetDeviceInfo.java

package jp.alldin.sdk.common;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.TextView;

public class GetDeviceInfo extends Activity {
TextView text;
public void getDeviceBaicInfo()//获取手机信息
{
TelephonyManager tm = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
String str = "";
str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion()+ "\n";
str += "Line1Number = " + tm.getLine1Number() + "\n";
str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
str += "NetworkType = " + tm.getNetworkType() + "\n";
str += "honeType = " + tm.getPhoneType() + "\n";
str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
str += "SimOperator = " + tm.getSimOperator() + "\n";
str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
str += "SimState = " + tm.getSimState() + "\n";
str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
text.setText(str);
}
public void getPhoneNumber() {
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imei = tm.getDeviceId();
String tel = tm.getLine1Number();
text.setText("a" + imei + "\n" + "b" + tel + "\n");
}
public void getDeciceNwStatus()//网络识别
{
ConnectivityManager connManager = (ConnectivityManager)this.getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
boolean available = networkInfo.isAvailable();
if(available)
{
Log.i("a", "a");
}
else
{
Log.i("b", "b");
}
android.net.NetworkInfo.State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
if(State.CONNECTED==state)
{
Log.i("c", "WIFI");
}
android.net.NetworkInfo.State state1 = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
if(State.CONNECTED==state)
{
Log.i("c", "GPRS");
}
startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));

}
}


css.java

package cs;


import jp.alldin.sdk.common.GetDeviceInfo;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class css extends Activity {
TextView textView1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
textView1 = (TextView)findViewById(R.id.textView1);
setContentView(R.layout.css);
a();

}
public static void a()
{
GetDeviceInfo getDeviceInfo= new GetDeviceInfo();
getDeviceInfo.getDeviceBaicInfo();
getDeviceInfo.getPhoneNumber();
getDeviceInfo.getDeciceNwStatus();

}

}



AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jp.alldin.sdk.common"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".css"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".GetDeviceInfo"
android:label="@string/app_name">
</activity>

</application>
</manifest>






...全文
570 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
书行 2011-10-28
  • 打赏
  • 举报
回复
你还没有设置布局呢,就去findView了,就找不到textView1了。
lizhengjun2010 2011-10-27
  • 打赏
  • 举报
回复
super.onCreate(savedInstanceState);
textView1 = (TextView)findViewById(R.id.textView1);
setContentView(R.layout.css);
a();


super.onCreate(savedInstanceState);
setContentView(R.layout.css);
textView1 = (TextView)findViewById(R.id.textView1);

a();
阿提饭 2011-10-27
  • 打赏
  • 举报
回复
css 不是布局文件吧,R.xml.css
talent1314 2011-10-27
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 lizhengjun2010 的回复:]

super.onCreate(savedInstanceState);
textView1 = (TextView)findViewById(R.id.textView1);
setContentView(R.layout.css);
a();


super.onCreate(savedInstanceState);
setContentView(R.layout.css);
textView1 = (TextView)findViewById(R.id.textView1);
a();
[/Quote]
为什么这样改了 还是报错呢

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧