The expanded_status_bar layout in AOSP 4.0.4 has a TextView that looks like this in the XML
<com.android.systemui.statusbar.policy.DateView
android:id="@+id/date"
android:textAppearance="@style/TextAppearance.StatusBar.Date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="4dp"
android:singleLine="true"
android:gravity="center"
android:visibility="visible" />
It is generated by “frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java”
It is inflated by “frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java” like so:
ExpandedView expanded = (ExpandedView) View.inflate(context, R.layout.status_bar_expanded, null);
// stuff here
mDateView = (DateView) expanded.findViewById(R.id.date);
I want to set its visibility via another class and I’ve tried a few things that I have read on here, all with no luck. The last thing I tried was, in my class (which is also part of systemui), to add the following:
TextView mDateView = (TextView) findViewById(R.id.date);
mDateView.setVisibility(View.GONE);
However, it turns out mDateView is null in my class. Is there something I am missing? I’ve been looking all over for hours and trying things here and there but nothing works. I have intermediate-level Java skills and I am still trying to wrap my arms around the OOP thing having coming from 20 years of procedural languages. Thanks in advance.
I changed mDateView’s definition to look like this:
private DateView mDateView;
DateView mDateView = (DateView) findViewById(R.id.date);
But I am still getting mDateView as being null 🙁
Initially i misunderstood your question, you can add methods in one class and access it via another.
You can add the following method in PhoneStatusBar.java and Call it later.