In the beginning: I am new in Android and Java programming, but I have a lot of experience with other programming languages like C, C++, Perl, PerlTk, OpenGL, Pascal, Microcontroller programming (C, Assembly), etc… I took a research and I tried a lot of things but nothing helped.
So I want to change the font size and font color in my listview.
I found 2 solutions:
-
Hacking the style. This is working, but if I modify my style than I have to modify all the other elements, what is building from this style. So no, and If I choose this method still I wont be able to modify the listview pressed and not pressed state background colors.
-
Custom layout. I prefer this method, but if I refer the layout, the eclipse says: “cannot be resolve, or is not a field”
My code:
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);
}
}
I wrote a custum layout and I put it in the layouts folder, and it is in the R folder too.
Still the Eclipse can’t see it… Maybe I have to import something? I am sure it is a noob Q but I will appreciate the answer.
Try using just:
instead of: