/*
 * Copyright 2012 Kulikov Dmitriy
 * Copyright 2017 Nikita Shakarun
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package javax.microedition.lcdui;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import javax.microedition.lcdui.event.SimpleEvent;

public class StringItem extends Item {
	private String text;
	private TextView textview;
	private int appearanceMode;

	private SimpleEvent msgSetText = new SimpleEvent() {
		@Override
		public void process() {
			textview.setText(text);
		}
	};

	public StringItem(String label, String text) {
		this(label, text, PLAIN);
	}

	public StringItem(String label, String text, int appearanceMode) {
		setLabel(label);
		setText(text);
		this.appearanceMode = appearanceMode;
	}

	public void setText(String text) {
		this.text = text;

		if (textview != null) {
			ViewHandler.postEvent(msgSetText);
		}
	}

	public String getText() {
		return text;
	}

	public Font getFont() {
		return Font.getDefaultFont();
	}

	public void setFont(Font font) {
	}

	public int getAppearanceMode() {
		return appearanceMode;
	}

	@Override
	public View getItemContentView() {
		if (textview == null) {
			Context context = getOwnerForm().getParentActivity();

			textview = new TextView(context);
			textview.setTextAppearance(context, android.R.style.TextAppearance_Small);
			textview.setText(text);
			textview.setOnClickListener(v -> fireDefaultCommandAction());
		}

		return textview;
	}

	@Override
	public void clearItemContentView() {
		textview = null;
	}
}
/*
 * Copyright 2012 Kulikov Dmitriy
 * Copyright 2017 Nikita Shakarun
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package javax.microedition.lcdui;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import javax.microedition.lcdui.event.SimpleEvent;

public class StringItem extends Item {
	private String text;
	private TextView textview;
	private int appearanceMode;

	private SimpleEvent msgSetText = new SimpleEvent() {
		@Override
		public void process() {
			textview.setText(text);
		}
	};

	public StringItem(String label, String text) {
		this(label, text, PLAIN);
	}

	public StringItem(String label, String text, int appearanceMode) {
		setLabel(label);
		setText(text);
		this.appearanceMode = appearanceMode;
	}

	public void setText(String text) {
		this.text = text;

		if (textview != null) {
			ViewHandler.postEvent(msgSetText);
		}
	}

	public String getText() {
		return text;
	}

	public Font getFont() {
		return Font.getDefaultFont();
	}

	public void setFont(Font font) {
	}

	public int getAppearanceMode() {
		return appearanceMode;
	}

	@Override
	public View getItemContentView() {
		if (textview == null) {
			Context context = getOwnerForm().getParentActivity();

			if (appearanceMode == BUTTON) {
				textview = new Button(context);
			} else {
				textview = new TextView(context);
			}

			textview.setTextAppearance(context, android.R.style.TextAppearance_Small);
			textview.setText(text);
			textview.setOnClickListener(v -> fireDefaultCommandAction());
		}

		return textview;
	}

	@Override
	public void clearItemContentView() {
		textview = null;
	}
}
Fix StringItem appearance