previously I apologized if my question is classic. but because I just learned Java programming for android, I didn't really understand the commands.
I'm currently making an application with the code section as follows:
Map<Integer, CompTypes> mapCompTypes = new java.util.HashMap();
class CompTypes
{
int androidId;
AndroidViewComponent component;
String text;
String type;
CompTypes(int androidId, AndroidViewComponent component, String type, String text)
{
this.androidId = androidId;
this.component = component;
this.type = type;
this.text = text;
}
}
public void SendMessage(HVArrangement container, String message, String dateTime, int fontSize, int fontColor, int alignment, int startid)
{
int id = Integer.parseInt(ChatBox.this.GetLastId());
TextBox comp = new TextBox(vertical);
comp.getView().setId(id);
comp.Text(message);
comp.FontSize(fontSize);
comp.TextColor(fontColor);
comp.MultiLine(true);
comp.Enabled(false);
comp.RequestFocus();
mapCompTypes.put(Integer.valueOf(id), new CompTypes(id, comp, compType, comp.Text()));
int id2 = id + 1;
Label dt = new Label(vertical);
dt.getView().setId(id2);
((TextView)dt.getView()).setText(android.text.Html.fromHtml(datetime));
dt.HTMLFormat(true);
dt.Text(datetime);
dt.getView().setOnClickListener(this);
dt.getView().setOnLongClickListener(this);
mapCompTypes.put(Integer.valueOf(id2), new CompTypes(id2, dt, compType, dt.Text()));
}
public String GetLastId()
{
// how to get last id?
//return ids;
}
at the moment I'm having trouble getting the value from id as the last id from Hashmap. I've read a number of questions and answers here that "Maps don't have the last entry, it's not part of their contract." is there another way to get the last id?