Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only last item visible. #151

Open
zakirpervez opened this issue Jul 16, 2019 · 0 comments
Open

Only last item visible. #151

zakirpervez opened this issue Jul 16, 2019 · 0 comments

Comments

@zakirpervez
Copy link

zakirpervez commented Jul 16, 2019

Screenshot_2019-07-16-18-07-49-84_108b1e62c8d71ee70e8168a20dd789ae
I am using kotlin as well as java

<fr.ganfra.materialspinner.MaterialSpinner
android:id="@+id/spnPrimaryGrowthStage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen_8"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:ms_baseColor="@color/separator_black"
app:ms_floatingLabelColor="@color/colorPrimary"
app:ms_floatingLabelText="@string/select_growth_stage"
app:ms_highlightColor="@color/colorPrimary"

	app:ms_hint="@string/primaryGrowthStage"
	app:ms_hintColor="@color/cool_grey_light"
	app:ms_multiline="true"/>

class PrimaryGrowthStageAdapter(private val context: Context, private val items: List) :
BaseAdapter() {

private var mView: View? = null

override fun getItem(position: Int): Any = items[position]

override fun getItemId(position: Int): Long = position.toLong()

override fun getCount(): Int = items.size

override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
	val viewHolder: ViewHolder
	if (mView == null) {
		mView = LayoutInflater.from(context).inflate(R.layout.spinner_item, parent, false)
		viewHolder = ViewHolder()
		viewHolder.tvTitle = mView!!.findViewById(R.id.tvTitle) as TextView
		mView!!.tag = viewHolder
	} else {
		viewHolder = mView!!.tag as ViewHolder
	}

	viewHolder.tvTitle!!.text = items[position].growthStageTitle
	viewHolder.tvTitle!!.setTextColor(Color.BLACK)

	return mView!!
}


class ViewHolder {
	var tvTitle: TextView? = null
}

}

private void populatePrimaryGrowthStageSpinner(@nonnull List primaryGrowthStageItems) {
primaryGrowthStageAdapter = new PrimaryGrowthStageAdapter(getApplicationContext(), primaryGrowthStageItems);
spnPrimaryGrowthStage.setAdapter(primaryGrowthStageAdapter);
spnPrimaryGrowthStage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@OverRide
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position > 0) {
mSelectedPrimaryGrowthStage = (TempPrimaryGrowthStageItem) parent.getSelectedItem();
if (mSelectedPrimaryGrowthStage != null) {
getSecondaryGrowthStage(mSelectedPrimaryGrowthStage.getGrowthStageId());
}
}
}

		@Override
		public void onNothingSelected(AdapterView<?> parent) {

		}
	});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant