Hi all!
First of all, Iam familiar with programming like C++, XML+++++, but I cant figure out this error I get in my XML-file, so far I am on step 6 where I should create the XML file that includes the new layout to the array.
Code:
<?xml version="1.0" encoding="utf-8"?>
<no.schedules.android.showSchedule
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_heigth="fill_parent"
android:padding="10dp"
android:scollbars="vertical"
andorid:textColor="@color/notepad_text"
android:fadingEdge="vertical"
/>
I've got this error: "error: Error parsing XML: unbound prefix", normally this is a error that appears when I misspelled something in the XML-file like anroid instead of android. But I guess the xml file cant find the packed or the class showSchedule. I have followed the tutorial correctly, but with some minor changes, like changing some class names, parameters to functions and I've given datatypes a different name.
This is what I've done so far:
Created two classes:
Schedules.java
Code:
package no.schedules.android;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
public class Schedules extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView list = (ListView)findViewById(R.id.liste);
final EditText textEdit = (EditText)findViewById(R.id.edit);
final ArrayList<String> schedule = new ArrayList<String>(); //oppretter array som viser timeplaner
final ArrayAdapter<String> scheduleArray;
scheduleArray = new ArrayAdapter<String>(this, R.layout.schedules_item, schedule);
list.setAdapter(scheduleArray);
textEdit.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(event.getAction() == KeyEvent.ACTION_DOWN)
if(keyCode == KeyEvent.KEYCODE_DPAD_DOWN){
schedule.add(0, textEdit.getText().toString());
scheduleArray.notifyDataSetChanged();
textEdit.setText("");
return true;
}
return false;
}
});}}
showSchedule.java
Code:
package no.schedules.android;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.TextView;
public class showSchedule extends TextView {
private Paint marginPaint;
private Paint linePaint;
int paperColor;
float margin;
public showSchedule(Context context, AttributeSet ats, int a){ super(context, ats, a); init(); }
public showSchedule(Context context) { super(context); init(); }
public showSchedule(Context context, AttributeSet attrs) { super(context, attrs); init(); }
private void init() {
Resources pickResource = getResources();
marginPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
marginPaint.setColor(pickResource.getColor(R.color.notepad_margin));
linePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
linePaint.setColor(pickResource.getColor(R.color.notepad_lines));
paperColor = pickResource.getColor(R.color.notepad_paper);
margin = pickResource.getColor(R.color.notepad_margin);
}
@Override
public void onDraw(Canvas canvas) {
canvas.drawColor(paperColor);
canvas.drawLine(0, 0, getMeasuredHeight(), 0 , linePaint);
canvas.drawLine(0, getMeasuredHeight(), getMeasuredWidth() , getMeasuredHeight(), linePaint);
canvas.drawLine(margin, 0, margin, getMeasuredHeight(), marginPaint);
canvas.save();
canvas.translate(margin, 0);
super.onDraw(canvas);
canvas.restore();
}
}
Both files are located under the packed no.schedules.android in eclipse.
What am I doing wrong here? I appreciate all answers. Thanks!