刚开始时,我是安卓和Java编程的新手,但我对C,C++,Perl,PerlTk,OpenGL,Pascal,微控制器编程(C,汇编)等编程语言有丰富的经验.我做了一项研究,我尝试了很多东西,但没有任何帮助。
所以我想改变我的列表视图中的字体大小和字体颜色。我找到了两个解决方案:
我的代码:
public class Btcall extends Activity
{
private ListView list;
final int REQUEST_ENABLE_BT = 1;
TextView kiirni;
TextView scanned;
View view2;
View view3;
Button connectbutton;
private ArrayAdapter<String> founddevices = null;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_btcall);
view2=(View) findViewById(R.id.view2);
view3=(View) findViewById(R.id.view3);
connectbutton=(Button) findViewById(R.id.button1);
kiirni=(TextView)findViewById(R.id.text1);
scanned=(TextView)findViewById(R.id.scanned);
list = (ListView) findViewById(R.id.list1);
}
public void irddki(View v)
{
BluetoothAdapter bluetooth = null;
BroadcastReceiver mReceiver = null;
bluetooth = BluetoothAdapter.getDefaultAdapter();
founddevices = null;
if(bluetooth != null)
{
String status;
if (bluetooth.isEnabled())
{
String mydeviceaddress = bluetooth.getAddress();
String mydevicename = bluetooth.getName();
status = mydevicename + " : " + mydeviceaddress;
Toast.makeText(this, status, Toast.LENGTH_LONG).show();
bluetooth.startDiscovery();
mReceiver = new BroadcastReceiver()
{
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action))
{
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
founddevices.add(device.getName() + "\n" + device.getAddress());
}
}
};
scanned.setVisibility(View.VISIBLE);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(470, 270, 0, 0);
connectbutton.setLayoutParams(lp);
connectbutton.setText("Scan again");
kiirni.setVisibility(View.GONE);
list.setBackgroundResource(R.color.Lightgrayy);
list.setVisibility(View.VISIBLE);
view2.setVisibility(View.VISIBLE);
view3.setVisibility(View.VISIBLE);
/*HERE IS THE PROBLEM--->*/
founddevices = new ArrayAdapter<String>(this, android.R.layout.mylist);
list = (ListView) findViewById(R.id.list1);
list.setAdapter(founddevices);
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(mReceiver, filter);
}
else
{
if (!bluetooth.isEnabled())
{
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
}
}
}
public void close(View v)
{
moveTaskToBack(true);
}
}我写了一个立方体布局,我把它放在布局文件夹,它也在R文件夹中。
但是Eclipse看不到它..。也许我得进口些什么?我相信这是一个问题,但我会感激的答案。
发布于 2012-12-09 14:13:25
试着使用以下方法:
R.layout.mylist而不是:
android.R.layout.mylisthttps://stackoverflow.com/questions/13787914
复制相似问题