Question
The line graph below uses scalable vector graphics (SVG) to plot the data. The chart uses the element to plot the data, but plots the
The line graph below uses scalable vector graphics (SVG) to plot the data. The chart uses the
The chart is plotted in an SVG canvas of size 400x700 pixels (shown by the large box). The coordinates of the upper-left and lower-right corners of this box are shown, and specifically that the origin of the SVG drawing canvas is in the upper-left.
Drawing the
We will use the SVG group
The order of transformations may seem backwards, but it is best to think of these as functions, e.g. translate(scale(datapoint)).
You will need to figure out the appropriate scaling factors xs, ys and translation offsets xo,yo to convert the
public class MainActivity extends AppCompatActivity {
ToDoListDB toDoListDB; List
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
txtName = (EditText) findViewById(R.id.txtName);
toDoListDB = new ToDoListDB(this); arrayList = toDoListDB.getList();
adapter = new ToDoListAdapter(this, (ArrayList
ListView listView = (ListView) findViewById(R.id.lstView); listView.setAdapter(adapter); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView> arg0, View arg1, int position, long arg3) { removeItemFromList(position); return true; } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView> parent, View view, int position, long id) { selectedToDo = arrayList.get(position); selectedPosition = position; txtName.setText(selectedToDo.getName()); addBtn = (Button) findViewById(R.id.btnAdd); addBtn = (Button) findViewById(R.id.btnAdd);addBtn.setText("Update");update = true;
// add an appropriate addBtn() call here
} });
addBtn = (Button) findViewById(R.id.btnAdd); addBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String name = txtName.getText().toString(); addBtn.setText("Add");
// add your code here
} });
Button clearBtn = (Button) findViewById(R.id.btnClear); clearBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { reset(); } });
Button allBtn = (Button) findViewById(R.id.btnAll); allBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(getBaseContext(), AllTasksActivity.class); startActivity(intent); } }); }
protected void removeItemFromList(final int position) { AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
alert.setTitle("Delete"); alert.setMessage("Do you want delete this item?"); alert.setPositiveButton("YES", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ToDo toDo = arrayList.get(position);
arrayList.remove(position); adapter.notifyDataSetChanged(); adapter.notifyDataSetInvalidated();
toDoListDB.remove(toDo.getId()); reset(); } }); alert.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } });
alert.show(); }
protected void reset() { txtName.setText("");
// add an appropriate addBtn() call here
selectedToDo = null; selectedPosition = -1; } }
class ToDoListAdapter extends ArrayAdapter
@Override public View getView(int position, View convertView, ViewGroup parent) { ToDo toDo = getItem(position);
if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(android.R.layout.simple_list_item_1, parent, false); }
TextView name = (TextView) convertView.findViewById(android.R.id.text1); name.setText(toDo.getName());
return convertView; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started